Skip to content

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

Description

@m-faizan-saeed

Version

Version : 0.8.0-2.1 , Installed From : cachyos-extra-v4

Describe the Bug

When using ouch decompress with the --dir flag pointing to an existing directory, ouch prompts for a file conflict on that parent directory. If the user selects (o)verwrite, ouch completely purges all other existing files and subdirectories inside that parent folder before unpacking the archive.

According to the official release page, this specific folder-wiping bug was supposedly fixed in version 0.8.0. However, this report demonstrates a critical regression or edge-case recurrence of the issue in the current 0.8.0-2.1 build.

Steps to Reproduce

  1. Create a directory structure with files and folders inside it.
  2. Run ouch d <archive>.zip --dir <path_to_existing_directory>
  3. When prompted with Handle file conflict for "...": [(R)ename/(m)erge/(o)verwrite/(s)kip], select o (overwrite).
  4. Check the contents of the parent directory.

Environment

  • Ouch Version: 0.8.0-2.1
  • OS/Distribution: Arch Linux / CachyOS (x86_64_v4 variant)
  • Install Source: cachyos-extra-v4
  • Build Date: Sun 05 Jul 2026

Current Behavior

The entire contents of the target parent directory are completely deleted without warning before extraction begins.

Terminal Logs / Proof of Concept

❯ ls Desktop/ouch-test/
drwxr-xr-x - cachyos  6 Aug 10:23  dir1
drwxr-xr-x - cachyos  6 Aug 10:23  dir2
drwxr-xr-x - cachyos  6 Aug 10:23  dir3
.rw-r--r-- 0 cachyos  6 Aug 10:22  file1.txt

~
❯ ouch d ~/GDrive/temp/scrapper_2.zip --dir Desktop/ouch-test/
Handle file conflict for "Desktop/ouch-test": [(R)ename/(m)erge/(o)verwrite/(s)kip]
o
[INFO] Directory "Desktop/ouch-test/scrapper_2" created
...
[INFO] Successfully decompressed archive to "Desktop/ouch-test"
[INFO] Files unpacked: 7

~ 48s
❯ ls Desktop/ouch-test/
drwxr-xr-x - cachyos  6 Aug 10:25  scrapper_2

Expected Behavior

Selecting overwrite should either only overwrite files with overlapping names within the archive's output context, or merge safely. It should not wipe out completely unrelated sibling directories and files sharing the parent path.

Additional Information

Terminal Logs Complete Output

❯ ls Desktop/ouch-test/
drwxr-xr-x - cachyos  6 Aug 10:23  dir1
drwxr-xr-x - cachyos  6 Aug 10:23  dir2
drwxr-xr-x - cachyos  6 Aug 10:23  dir3
.rw-r--r-- 0 cachyos  6 Aug 10:22  file1.txt

~
❯ ouch d ~/GDrive/temp/scrapper_2.zip --dir Desktop/ouch-test/
Handle file conflict for "Desktop/ouch-test": [(R)ename/(m)erge/(o)verwrite/(s)kip]
o
[INFO] Directory "Desktop/ouch-test/scrapper_2" created
[INFO] extracted (  8.00   B) "Desktop/ouch-test/scrapper_2/.gitignore"
[INFO] Directory "Desktop/ouch-test/scrapper_2/src" created
[INFO] extracted (291.00   B) "Desktop/ouch-test/scrapper_2/src/main.rs"
[INFO] extracted (  5.45 kiB) "Desktop/ouch-test/scrapper_2/src/scratchpad.txt"
[INFO] extracted ( 49.59 kiB) "Desktop/ouch-test/scrapper_2/Cargo.lock"
[INFO] extracted (177.00   B) "Desktop/ouch-test/scrapper_2/Cargo.toml"
[INFO] Successfully decompressed archive to "Desktop/ouch-test"
[INFO] Files unpacked: 7

~ 48s
❯ ls Desktop/ouch-test/
drwxr-xr-x - cachyos  6 Aug 10:25  scrapper_2

~
❯ pacman -Qi ouch
Installed From  : cachyos-extra-v4
Name            : ouch
Version         : 0.8.0-2.1
Description     : A command line utility for easily compressing and decompressing files and directories
Architecture    : x86_64_v4
URL             : https://github.com/ouch-org/ouch
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : bzip3  glibc  libgcc  libstdc++  zstd
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 5.55 MiB
Packager        : CachyOS <admin@cachyos.org>
Build Date      : Sun 05 Jul 2026 06:39:53 AM PKT
Install Date    : Wed 05 Aug 2026 05:57:08 PM PKT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

I have lost all of my uncommitted projects (😅 ouch). Some how recovered some files.
I am really hesitant to use it again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions