This fixes an infinite recursion loop in getFile caused by:
1) `os.Stat(file)` resolves a symlink so that `fileInfo.isDir()` returns True
2) `filepath.Walk()` starts iterating on the root directory (in this case the symlink)
3) `filepath.Walk()` uses `os.Lstat` internally, which does NOT dereference the symlink
4) in the walk func, `f.isDir()` returns False, and the walk func calls `getFile()` on it
5) goto 1
fixes#47
Part-of: https://gitlab.postmarketos.org/postmarketOS/postmarketos-mkinitfs/-/merge_requests/65
Initially I thought of breaking off the Stat + error check call into its
own function as to reduce repetition, but given that it's only useful in
this situation where it only happens twice anyway, I'm not sure it
actually would reduce complexity.
Additionally, this means that .zst-compressed variants of files will be
searched for in all contexts where this function is used. I'm not sure
this is desirable.
Tested and works with arrow-db820c. I didn't test it on actual hardware,
but I verified that the firmware ended up in the initramfs via
$ pmbootstrap initfs ls. I choose this device because it uses firmware
from linux-firmware and also needs said firmware present in the
initramfs.
Closes https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/39
Now:
10:57:41.737665 initramfs-extra completed in: 0.33s
...
10:57:42.008587 boot-deploy completed in: 0.27s
10:57:42.012973 mkinitfs completed in: 0.90s
Times is just truncated, not rounding, since it's simpler (no dependency
on the math module), and I'm not sure if anyone cares for what this
function prints. If there is a desire to return to higher precision
later, it could be enabled by a new flag.
fixes https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/25