fix: skip duplicate archive entries instead of aborting extraction#137
Merged
fix: skip duplicate archive entries instead of aborting extraction#137
Conversation
1ff1192 to
6ed757a
Compare
6ed757a to
2d88bf2
Compare
) When `skip_duplicates` is true (default), entries whose destination path already exists on disk are skipped rather than causing an `os error 17` abort. The skip is recorded in `ExtractionReport.files_skipped` and a warning is appended to `ExtractionReport.warnings`. - Add `skip_duplicates: bool` (default `true`) to `ExtractionOptions` - Thread `ExtractionOptions` through `ArchiveFormat::extract` and all format-specific helpers (TAR, ZIP, 7z) - Handle duplicate files, symlinks, and hardlinks in `extract_file_generic`, `create_symlink`, and `create_hardlink` respectively - Add unit tests for skip (default) and error-on-duplicate (disabled) paths
696778f to
8bbe8fe
Compare
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.
Summary
Fixes #129. When a TAR/ZIP/7z archive contains two entries with the same path, exarch previously aborted with
File exists (os error 17). With this fix, conflicting entries are skipped gracefully and recorded in the extraction report.skip_duplicates: bool(defaulttrue) toExtractionOptionsskip_duplicatesis true and a destination path already exists: skip the entry, incrementExtractionReport.files_skipped, append a warning toExtractionReport.warningsskip_duplicatesis false: preserve the original abort-on-duplicate behaviorExtractionOptionsthroughArchiveFormat::extracttrait and all format implementationsTest plan
test_duplicate_entry_skip_default— TAR with twolegit.txtentries;files_extracted=1,files_skipped=1, first content preservedtest_duplicate_entry_error_when_disabled— same archive withskip_duplicates=false; extraction returns errorcargo +nightly fmt --all -- --checkcleancargo clippy --all-targets --all-features --workspace -- -D warningscleanRUSTDOCFLAGS="-D warnings" cargo doccleancargo deny checkclean