-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add option to always extract to output_dir named after the archive even on single/one file #766
Comments
I feel you. I've had people complain both ways in the past, cause So we ended up with this mixed behavior to try to make everyone happy but it's completely unpredictable, and I can't expect people to remember to pass a flag every time they run Ouch, with that in mind, I still think the correct answer is to change the default and not just add an option 🤔. (For reference, in issues and in the code we refer to this as "smart_unpack".) I'm starting to lean towards making your suggestion the default behavior, and in the future, maybe delegating I'd appreciate some help making these decisions 😆, considering all of this, do you think we should prioritize the safer defaults that cause less conflicts but might be slightly more annoying? @killercup you've been helping recently, can I ask for your opinion about this too? |
From my experience in using software, for general every-day use, I would prefer software to be smart by default as it automates a lot of processes that the user usually would do. However, it's when those automated processes aren't needed, or get in the way of what needs to be done. In cases like this, I find it desirable to be able to temporarily turn off the smart features and go back to the basics so that it becomes part of the process, not the entire process. This lets people use scripts (or manual work) to trivially extend the behavior for various applications and integrations. In my use case, I have a plugin for Yazi (a terminal file explorer) that allows me to decompress multiple archives. It will automatically say "Yes" to everything, including overwrites. I selected multiple archives and decompressed them, and a lot of files were lost because they were overwritten (because single file). While ouch is supposed to ask the user if they want to overwrite the file, this plugin behavior is potentially destructive as it could overwrite irrelevant but important files (e.g. The argument could also be applied in the scenario where an archive extracts to a directory named after itself, but an existing directory already exists. I'm not too sure how ouch handles this, but to be non-destructive, I would assume it renames it with a number (i.e. In short, I think prioritizing safer defaults that cause less conflicts but might be slightly less annoying is a good approach. The default should not be to overwrite, as it's destructive, and to instead append the new file/folder with a number (i.e. |
Not sure I have a strong opinion here. The range of options I see
|
OH, you're using this in a script, and with I completely misinterpreted that. All interface decisions were made with user interaction in mind, scripting was never a priority and there is a lot of room for improving in this direction. @uwidev I believe what you want is Closing this in favor of that, let me know if you think we should re-open. (currently Thanks you both for the input, I opened #767 to not lose track of the renaming suggestion. |
I misinterpreted the implementation in Yazi. It turns out the integration into Yazi does not utilize ouch to extract archives (by default). during testing, the decompression functionality was exactly the same (smart unpack). Regardless, my issue still stands for ouch (I think it's very cool and want to use it more). And the script was just an example. Maybe I want to do something like But there raises another problem and perhaps the real problem: keeping track of which files belonged to which archive. The rename solution is a bandage fix, because now I have to deal with figuring out which file The And honestly, I think that's the emerging, real issue here: not being able to keep track of which single file(s) belonged to which archive. Smart unpack will move a single file in a single-file-archive to the root directory, and if there are multiple single-file-archives, whether they overwrite or rename, you cannot reasonably tell at a glance which file belonged to which archive. Having smart unpack be a toggle to always extract to a newly created archive-folder name would solve this since you can now visually link that Addition: So giving that some thought, I'm actually a bit disoriented about smart unpacking. How is the user supposed to know what they're supposed to be expecting when they extract the file? They almost always don't, hence why the same-named folder method worked so well. With smart unpacking, if the archive contains a single file, there's now no way to link that file to the original archive, so good luck trying to find that extracted file in a messy directory (e.g. downloads). |
I highly appreciate the quality of your feedback. If I had to summarize, I see two concerns:
Point 1You convinced me :), we need a flag to disable smart unpack, I'll reopen this issue in a bit. (Still think Point 2I think we can solve this with communication, by improving the output.
All of this looks... very messy. But the important line here is:
If instead we could have the last line say this:
I think that would be clear enough! What do you think? |
While I would say we could just knock two birds with one stone just by completely disabling smart unpacking, thus always moving files to a folder of the same archive name, I understand the usefulness it. I definitely think an adjustment to stdout would be appreciated. I prefer simplicity in symbols over text.
Alternatively, use Might I also suggest hiding the backend operations to |
Currently,
This is also a great feature, and I'd like ouch can support them in seperate options, so that we can use them in different cases. |
Yes. To be more precise, I hope to have an effect consistent with unzip -od.
10 Mar 2025 07:17:38 João Marcos ***@***.***>:
…
[Image][marcospb19][https://avatars.githubusercontent.com/u/38900226?s=20&v=4]*marcospb19* left a comment (ouch-org/ouch#766)[#766 (comment)]
@Vonfry[https://github.com/Vonfry] do you want #322[#322]? Sorry I don't quite understand.
—
Reply to this email directly, view it on GitHub[#766 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AA2BI72VCRNQHSLXHMKYGQ32TTDZBAVCNFSM6AAAAABW7Z5A3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMBZGEZDIMZTGY].
You are receiving this because you were mentioned.
|
I wasn't initially aware of this behavior, but when extracting an archive that only has one element, the extracted file gets placed in the root directory (where the extract occurred) rather than a created directory named after archive. This actually resulted in problems for me when having multiple archives that just so happen to have a single file with the same name. This resulted in the filenames colliding and overwriting each other.
Would you consider having a option to always create a folder even if there is only one file?
The text was updated successfully, but these errors were encountered: