Add Entry::set_path_bytes#448
Open
RemiBardon wants to merge 1 commit into
Open
Conversation
This allows mapping paths when unpacking an archive.
RemiBardon
added a commit
to RemiBardon/tar-rs
that referenced
this pull request
Apr 19, 2026
This allows mapping paths while extracting, if [composefs#448] gets merged. See the above pull request for rationale regarding this addition. [composefs#448]: composefs#448
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This allows mapping paths when unpacking an archive.
Context
I’m working on a backup system, which uses tar as the archive format. Backups must be immutable, but still be restorable after schema (file hierarchy) changes. For this I implemented migrations, which are basically just path mappings.
At first I was unpacking in a temporary directory, renaming directories, then moving them to their final destination. It was simple and effective, but it broke when I realized I had to unpack in mounted paths (and
fs::renamedoesn’t work across devices).I thought about using symlinks, but the I/O overhead is massive if paths have to be resolved for every single archive entry. The other obvious solution was to map paths while unpacking the archives. Unfortunately, the crate doesn’t provide any API for that and I’d have to re-implement a lot of logic to get it working (security footgun).
Here is a tiny one-liner which exposes just what one needs to unlock this use case. Ideally I’d like a way to not have to re-implement
tar::Archive::unpack, but it’s acceptable (not too much logic). I might submit another PR if I find an API that’d qualify as a patch without affecting performance (and without duplicating code).By the way thank you for the library, it’s great!