Skip to content

Merge folders in decompression #798

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

Merged
merged 10 commits into from
May 1, 2025
Merged

Conversation

tommady
Copy link
Contributor

@tommady tommady commented Apr 18, 2025

try to
close #466
close #727

I am very open-minded to accepting any suggestions.
The image below is just an example of fulfilling the purpose of those issues.

image

@marcospb19 marcospb19 changed the title intro merge action in decompression Merge folders in decompression Apr 18, 2025
Copy link
Member

@marcospb19 marcospb19 left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! I never before considered this could be an option in the prompt instead of the default, it seems like a good idea so I'm thinking about letting that be.

Can you add a test that unpacks two archives with the following structures:

a/b/c/1

and

a/b/c/2

And show that when decompressed and provided m via stdin, they will merge into:

a/
 b/
  c/
   1
   2

You can start from a copy of multiple_files_with_conflict_and_choice_to_rename that uses the 'allow_piped_choice' feature flag (which we should someday turn into a flag), with that you can pass the stdin choice you want.

Copy link
Member

@marcospb19 marcospb19 left a comment

Choose a reason for hiding this comment

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

This is also on a good path for merging :) so don't forget a changelog entry, I think the PR title reflects this change well.

@marcospb19 marcospb19 force-pushed the main branch 7 times, most recently from 9ee3fd8 to 739dfa9 Compare April 18, 2025 20:57
@tommady
Copy link
Contributor Author

tommady commented Apr 19, 2025

Thanks for this PR! I never before considered this could be an option in the prompt instead of the default, it seems like a good idea so I'm thinking about letting that be.

Can you add a test that unpacks two archives with the following structures:

a/b/c/1

and

a/b/c/2

And show that when decompressed and provided m via stdin, they will merge into:

a/
 b/
  c/
   1
   2

You can start from a copy of multiple_files_with_conflict_and_choice_to_rename that uses the 'allow_piped_choice' feature flag (which we should someday turn into a flag), with that you can pass the stdin choice you want.

I am stuck on how to write the test. Thanks for your guidance. very appriceiate!

@marcospb19 marcospb19 force-pushed the main branch 3 times, most recently from 91103b1 to 2b9da1e Compare April 21, 2025 02:05
@tommady tommady marked this pull request as ready for review April 22, 2025 04:52
Signed-off-by: tommady <[email protected]>
@tommady tommady requested a review from marcospb19 April 24, 2025 10:55
Copy link
Member

@marcospb19 marcospb19 left a comment

Choose a reason for hiding this comment

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

looking good

We decided that #798 (comment) can be addressed later.

@marcospb19 marcospb19 merged commit 1ff1932 into ouch-org:main May 1, 2025
15 checks passed
@tommady tommady deleted the close-issue-466-727 branch May 2, 2025 01:45
@marcospb19
Copy link
Member

Hey, I found a bug around this implementation:

$ mkdir parent/
$ touch parent/a
$ ouch c parent a.tar
[INFO] Compressing 'parent'
[INFO] Compressing 'parent/a'
[INFO] Successfully compressed 'a.tar'
$ mv parent/a parent/b
$ ouch c parent b.zip
[INFO] Compressing 'parent'
[INFO] Compressing 'parent/b'
[INFO] Successfully compressed 'b.zip'
$ rm parent -fr
$
$ ouch d a.tar
[INFO] Created temporary directory /home/marcospb19/./tmp-ouch-dhhuxX to hold decompressed elements
[INFO] extracted (  0.00   B) "tmp-ouch-dhhuxX/parent"
[INFO] extracted (  0.00   B) "tmp-ouch-dhhuxX/parent/a"
[INFO] Successfully moved "/home/marcospb19/./tmp-ouch-dhhuxX/parent" to "./parent"
[INFO] Successfully decompressed archive in current directory
[INFO] Files unpacked: 2
$ ouch d b.zip
[INFO] Created temporary directory /home/marcospb19/./tmp-ouch-ECtvGC to hold decompressed elements
[INFO] File 0 extracted to "/home/marcospb19/./tmp-ouch-ECtvGC/parent/"
[INFO] extracted (  0.00   B) "tmp-ouch-ECtvGC/parent/b"
Do you want to overwrite ./parent? [y/n/r/m]
m
[ERROR] failed to rename file from /home/marcospb19/./tmp-ouch-ECtvGC/parent to ./parent

Looks like a scenario we forgot to test.

@tommady
Copy link
Contributor Author

tommady commented May 18, 2025

thank you, I created an issue and I'll fix it.

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.

Decompressing multiple archives conflicts with overwrite prompt Overwrite behavior removes files differently than expected
2 participants