Do not fail on symlinks that point to non-empty files, use default tar behavior #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using this package in a Docker image I maintain and an issue was raised where it seems that
targz
seems to fail on symlinks that point to non-empty files, failing with:It seems this is due to the fact that package
targz
resolves symlinks to use the proper file instead, but still uses thefileInfo
of the symlink itself, which means the size written to the header info does not match anymore.As for how to fix this there are two options:
targz
use the default behavior of thetar
command which is keeping the symlink a symlink (potentially risking a broken symlink that points to something out of the bounds of the archive)targz
use the behavior that seems to be the one intended by the code (but isn't working), which is to resolve the symlinks and include their backing contentI opted for choosing 1 for now as it's the default of
tar
, but if you feel like 2 is the better fit for this package I am happy to change this as again.As for the issue itself, you can repro this easily by checking out the first commit in this changeset which just updates the test setup to include a symlink to a non-empty file, which makes tests fail.