Skip to content

Add Entry::set_path_bytes#448

Open
RemiBardon wants to merge 1 commit into
composefs:mainfrom
RemiBardon:set-path-bytes
Open

Add Entry::set_path_bytes#448
RemiBardon wants to merge 1 commit into
composefs:mainfrom
RemiBardon:set-path-bytes

Conversation

@RemiBardon
Copy link
Copy Markdown

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::rename doesn’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!

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant