alexcrichton / tar-rs

Tar file reading/writing for Rust
https://docs.rs/tar
Apache License 2.0
625 stars 184 forks source link

Feature: Automatic renaming of duplicate files in archive #290

Open junbl opened 2 years ago

junbl commented 2 years ago

Archives can contain multiple files with the same name. By default, the duplicates are overwritten. The set_overwrite method changes this so that duplicates cause errors. It'd be useful if there was a way to modify the duplicate paths somehow so that archives with duplicate filenames can be extracted easily.

For example, when 7zip encounters duplicates, it gives you the option to auto-rename, which inserts a _n before the extension of each duplicate file. E.g., the second duplicate.txt would become duplicate_1.txt, then duplicate_2.txt, etc. Might be fun if you could pass a closure (e.g. Fn(&str, usize) -> &str) to determine your own rename policy.