-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accurate mtimes for directories, overwrite symlinks, preserve ownership #217
base: main
Are you sure you want to change the base?
Conversation
…erwrite behaviour when extracting symlinks
Thanks for the PR! This looks somewhat invasive though, so can you provide some more rationale for these changes? Why do we want to match the |
You're welcome. I opened this on a whim. I just thought maybe someone else might benefit from my efforts and completely forgot to create an issue or check whether or not PRs were even welcome.
It matches behaviour, not the CLI. And frankly, the behaviour is now what I would have expected in the first place. I feel an archiving tool, especially at the layer of a general purpose library, should never modify data on its own. This might be a matter of bias, as I have experience with forensic work, but to me, getting things out of the box I put them into must never change those things. And differing metadata might matter, eg. when using rsync. Sometimes an archive has the purpose of a time capsule, and especially for testing purposes, exact replication can be required. If a consumer of this library does not care about fidelity (or deliberately decides not to leak timestamps and ownership), that would be the right context to make this decision. I currently work on a project that aims for producing a single, statically linked binary and an external tar command would be cumbersome to integrate into the workflow when "a few changes" could make that unnecessary. PS: Unfortunately, I have no access to a windows system to run tests myself. I was unable to deduce from reading the code where the failure originates. |
Would be nice to have an ability to overwrite symlinks. Not that it should be enabled by default, but it seems like some clients out wild expect symlinks to be overwritten (e.g. camallo/dkregistry-rs/issues/149). |
I agree. @moschroe thank you for implementing this! Would you be wiling to split that change to a separate PR? I'm hopeful that will increase the chances of merging this feature. |
Rough draft on how this could be done.
Accurate mtime for directories
Copies the behaviour of
tar
where each directory will be queued to have its timestamps modified after all files have been extracted. Otherwise, any directory with any files contained will be modified the instant those files are extracted.Overwrite symlinks
Minor inconsistency, files were overwritten, symlinks were not. Now, this behaviour is consistent and configurable. (Maybe make the default
true
?)Preserve ownership
On unix platforms, perform
chmod
on all extracted entries. For any uid different from the user of the process, this will only work when running as uid 0 or using fakeroot (if linked dynamically).