Skip to content

fix: prevent destructive overwrite of decompression directories - #1044

Merged
marcospb19 merged 2 commits into
ouch-org:mainfrom
fzlzjerry:fix/decompress-directory-overwrite
Sep 2, 2026
Merged

fix: prevent destructive overwrite of decompression directories#1044
marcospb19 merged 2 commits into
ouch-org:mainfrom
fzlzjerry:fix/decompress-directory-overwrite

Conversation

@fzlzjerry

Copy link
Copy Markdown
Contributor

Closes #1043.

Summary

  • remove the destructive overwrite choice when a decompression conflict target is a directory
  • keep rename, merge, and skip for directory conflicts while preserving overwrite for actual file conflicts
  • update the multi-format merge coverage and add regressions for preserving unrelated directory contents and overwriting a single-file target
  • document the fix in the changelog

Validation

  • cargo test --locked
  • cargo test --locked --no-default-features
  • cargo test --locked --no-default-features --features unrar,use_zlib,use_zstd_thin
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo clippy --locked --no-default-features --all-targets -- -D warnings
  • cargo +nightly fmt -- --check

@fzlzjerry
fzlzjerry marked this pull request as ready for review August 11, 2026 08:57
Copilot AI lite review requested due to automatic review settings August 11, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@marcospb19

Copy link
Copy Markdown
Member

review requested due to automatic review settings

wat, uh, oke, Imma ignore that

@marcospb19

Copy link
Copy Markdown
Member

remove the destructive overwrite choice when a decompression conflict target is a directory

Did you choose that by accident and had an unintended deletion? Do you think the conflict message was confusing and could be improved?

@fzlzjerry

Copy link
Copy Markdown
Contributor Author

No, I did not lose data myself; I reproduced the behavior reported in #1043. The prompt says overwrite, but for an explicit --dir it does not make clear that this recursively removes the entire existing destination, including unrelated contents. The reporter expected archive collisions to be overwritten and lost unrelated projects, which is why I removed the directory-level option. If you prefer to keep it, I can narrow the patch to an explicit destructive warning/confirmation instead.

@marcospb19
marcospb19 force-pushed the fix/decompress-directory-overwrite branch from 71f8ab6 to bc5e0df Compare September 2, 2026 04:48

@marcospb19 marcospb19 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of renaming it to delete instead of overwrite so that we didn't remove the capability of deleting it.

But maybe you're right, we should just remove any possibility of messing up while using ouch, even if that means requiring the user to manually run some rm in corner cases.

@marcospb19

Copy link
Copy Markdown
Member

I rebased and now CI is failing, I'll be trying to fix.

@marcospb19
marcospb19 merged commit 015fe61 into ouch-org:main Sep 2, 2026
18 checks passed
@marcospb19

Copy link
Copy Markdown
Member

Thanks!

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.

Bug: Decompressing with --dir flag and choosing 'overwrite' wipes parent directory contents

3 participants