-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Version
385a630 (main branch)
Description
When compressing an archive like .tar
, if the output file is inside of the input folder, Ouch enters an infinite compression state.
That's because the output is being considered as the output, so any written bytes are read again, and again, and that's an infinite loop.
Current Behavior
$ ouch compress . archive.tar
Runs forever and will slowly exhaust all your hard drive space.
Example compressing a 2 GB folder:
Expected Behavior
Ouch should ignore the output as the input file, like tar
util does.
$ tar -cvf archive.tar .
...
...
tar: ./out.tar: file is the archive; not dumped
Additional Information
There is a check for skipping input files that are the same as the output file at
Lines 406 to 419 in 385a630
fn deduplicate_input_files(files: &mut Vec<PathBuf>, output_path: &Path) { | |
let mut idx = 0; | |
while idx < files.len() { | |
if files[idx] == output_path { | |
warning!( | |
"The output file and the input file are the same: `{}`, skipping...", | |
output_path.display() | |
); | |
files.remove(idx); | |
} else { | |
idx += 1; | |
} | |
} | |
} |
But in this case it's necessary to check while iterating in folder structures.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working