Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompressing multiple archives conflicts with overwrite prompt #727

Open
valoq opened this issue Oct 9, 2024 · 3 comments
Open

Decompressing multiple archives conflicts with overwrite prompt #727

valoq opened this issue Oct 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@valoq
Copy link
Contributor

valoq commented Oct 9, 2024

Version

0.5.1

Description

When decompressing multiple archives that contain the same file or directory names, ouch asks the user if the files should be overwritten multiple times, which can also be a random archive in the list:

Current Behavior

ouch decompress testA.zip testB.zip testC.zip
[INFO] Created temporary directory /tmp/experiment/./.tmpBER78Y to hold decompressed elements.
[INFO] File 0 extracted to "/tmp/experiment/./.tmpBER78Y/test/"
[INFO] Created temporary directory /tmp/experiment/./.tmpt6Uh2b to hold decompressed elements.
[INFO] ".tmpBER78Y/test/a" extracted. (4.00 B)
[INFO] Created temporary directory /tmp/experiment/./.tmp8oJZxo to hold decompressed elements.
[INFO] File 0 extracted to "/tmp/experiment/./.tmpt6Uh2b/test/"
[INFO] Successfully moved /tmp/experiment/./.tmpBER78Y/test to ./test.
[INFO] File 0 extracted to "/tmp/experiment/./.tmp8oJZxo/test/"
[INFO] Successfully decompressed archive in current directory (2 files).
[INFO] ".tmpt6Uh2b/test/b" extracted. (4.00 B)
[INFO] ".tmp8oJZxo/test/c" extracted. (4.00 B)
Do you want to overwrite './test'? [Y/n] Do you want to overwrite './test'? [Y/n]

Expected Behavior

The user should be prompted multiple times, one after another with specification of which archive is asking to overwrite the specified files.

Example:

Archive testB.zip: Do you want to overwrite './test'? [Y/n] n
Archive testC.zip: Do you want to overwrite './test'? [Y/n] Y

Additional Information

The example used in this report should not ask to overwrite any data since there are not file conflicts (directories with the same name should not be considered a conflict by default) See #466

(The test archives all contain the folder test and a single text file a, b and c respectively)
testA.zip
testB.zip
testC.zip

@valoq valoq added the bug Something isn't working label Oct 9, 2024
@marcospb19
Copy link
Member

First part:

Archive testB.zip: Do you want to overwrite './test'? [Y/n] n
Archive testC.zip: Do you want to overwrite './test'? [Y/n] Y

Great, I like the archive name with the question. Greelight given ✔️.


Second part:

The user should be prompted multiple times, one after another with specification of which archive is asking to overwrite the specified files.

About being prompted one after another, I don't know how that could be implemented, we iterate on each file and check if it conflicts.

But we don't know upfront whether or not paths will conflict.

Checking for all conflicts before decompressing should be possible for ".zip" since the header concentrates all paths, but I'm not sure about ".tar.gz", at least not without having to decompress it twice, which is undesirable.

Maybe it's possible to iterate through every .tar.gz file without really reading its contents, and this might be fast enough, but we'd need some benchmarks to make sure.

Would need someone to figure this out for me.

@valoq
Copy link
Contributor Author

valoq commented Oct 27, 2024

How about stopping the decompression whenever a conflict is detected and then wait for the user input to decide whether to overwrite the file or not? I believe this is also quite common behavior for this kind of issue.

@marcospb19
Copy link
Member

You can do so by decompressing 1 archive at a time, unfortunately, because Ouch descompresses in parallel, this is hard to do, even if we paused the other threads, we wouldn't be able to make it in a way that subsequent questions from the same archive appear one after the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants