Skip to content

fix: skip duplicate archive entries instead of aborting extraction#137

Merged
bug-ops merged 4 commits intomainfrom
129-duplicate-entry-skip
Mar 25, 2026
Merged

fix: skip duplicate archive entries instead of aborting extraction#137
bug-ops merged 4 commits intomainfrom
129-duplicate-entry-skip

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 25, 2026

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.

  • Add skip_duplicates: bool (default true) to ExtractionOptions
  • When skip_duplicates is true and a destination path already exists: skip the entry, increment ExtractionReport.files_skipped, append a warning to ExtractionReport.warnings
  • When skip_duplicates is false: preserve the original abort-on-duplicate behavior
  • Covers all entry types: regular files, symlinks, hardlinks (TAR), and 7z files
  • Thread ExtractionOptions through ArchiveFormat::extract trait and all format implementations

Test plan

  • test_duplicate_entry_skip_default — TAR with two legit.txt entries; files_extracted=1, files_skipped=1, first content preserved
  • test_duplicate_entry_error_when_disabled — same archive with skip_duplicates=false; extraction returns error
  • All existing 618 tests pass
  • cargo +nightly fmt --all -- --check clean
  • cargo clippy --all-targets --all-features --workspace -- -D warnings clean
  • RUSTDOCFLAGS="-D warnings" cargo doc clean
  • cargo deny check clean

@bug-ops bug-ops force-pushed the 129-duplicate-entry-skip branch from 1ff1192 to 6ed757a Compare March 25, 2026 21:09
@github-actions github-actions bot added core Changes to exarch-core docs Documentation tests Test changes benches Benchmark changes labels Mar 25, 2026
@bug-ops bug-ops force-pushed the 129-duplicate-entry-skip branch from 6ed757a to 2d88bf2 Compare March 25, 2026 21:10
@bug-ops bug-ops enabled auto-merge (squash) March 25, 2026 21:11
bug-ops added 4 commits March 25, 2026 22:29
)

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
@bug-ops bug-ops force-pushed the 129-duplicate-entry-skip branch from 696778f to 8bbe8fe Compare March 25, 2026 21:29
@bug-ops bug-ops merged commit 4eae1d3 into main Mar 25, 2026
20 checks passed
@bug-ops bug-ops deleted the 129-duplicate-entry-skip branch March 25, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benches Benchmark changes core Changes to exarch-core docs Documentation tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: duplicate entry name causes "File exists" abort instead of graceful skip

1 participant