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

Bug with nested dirs in u7z mkdir action #4559

Closed
mc-butler opened this issue Jul 9, 2024 · 7 comments
Closed

Bug with nested dirs in u7z mkdir action #4559

mc-butler opened this issue Jul 9, 2024 · 7 comments
Assignees
Labels
area: vfs Virtual File System support prio: medium Has the potential to affect progress
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/4559
Reporter ponko (ponkotsume@….com)

Current

$P7ZIP a -w"$dir" "$1" "$dir"/"$2" ..

Should be

$P7ZIP a "$1" "$dir/${2%%/*}" ..

Case1

  • open some 7z archive
  • press F7
  • type a/b/c, press enter
  • restart mc
  • open the archive
  • expected: "a", "a/b", "a/b/c" dirs
  • actual: "c" dir

Case2

  • left panel: open some 7z archive
  • right panel: create x/y/z path, copy x to the left
  • restart mc
  • open the archive
  • expected: "x", "x/y", "x/y/z" dirs
  • actual: "x", "y", "z" dirs

I could guess what one meant putting -w there, and it was completely wrong idea. -w option:

Sets the working directory for the temporary base archive. By default, 7-Zip builds a new base archive file in the same directory as the old base archive file. By specifying this switch, you can set the working directory where the temporary base archive file will be built. After the temporary base archive file is built, it is copied over the original archive; then, the temporary file is deleted.

By default, 7z only looks at the last part of the path. E.g. if we say "7z a 1.7z a/b/c", it adds the "c" dir. There is the "-spf" option (idk since which version) to make it use the whole path provided, but it means more code in our case:

cd "$dir"
$P7ZIP a -spf "$1" "$2" ..
cd -

The one-liner $P7ZIP a "$1" "$dir/${2%%/*}" .. looks better.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 27, 2024 at 9:40 UTC (comment 1)

  • Votes set to andrew_b
  • Owner set to andrew_b
  • Milestone changed from Future Releases to 4.8.32
  • Status changed from new to accepted
  • Branch state changed from no branch to on review

Branch: 4559_extfs_u7z_mkdir
[b8de3f3819b6c3b42111fcd50609f1d67a5dc9c3]

@mc-butler
Copy link
Author

Changed by ponko (ponkotsume@….com) on Jul 27, 2024 at 11:11 UTC (comment 2)

Andrew, I need to clarify something in the comment text. The "by default, 7z only looks at the last part of the path" is only true for ABSOLUTE pathes. u7z operates on absolute pathes and my patch works, but the commit text should be changed:

this

If we need to create dir "z" in an archive under path "x/y/", such command
works: `mkdir -p x/y/z && 7z a some.7z x`. If the disposable subdirs should be
created not in the current dir, but under some $temp dir, it would be `mkdir -p
$temp/x/y/z && 7z a some.7z $temp/x`.

should be replaced with

When adding something to a 7z archive by its absolute path, 7zip only uses the
last part of the path by default. E.g. `7z a 1.7z /tmp/a/b/date.txt` would add
date.txt to the root dir inside the archive. If we wanted the file to be under
`a/b/` inside the archive as well, it should be `7z a 1.7z /tmp/a`.

@mc-butler
Copy link
Author

Changed by ponko (ponkotsume@….com) on Jul 27, 2024 at 11:23 UTC (comment 3)

Also, in the post text above my description of the -spf option is wrong. The option is only related to ABSOLUTE pathes again:

  • 7z a 1.7z /tmp/a/b/date.txt would add date.txt to the root dir inside the archive
  • 7z a -spf 1.7z /tmp/a/b/date.txt would add date.txt to the archive as /tmp/a/b/date.txt

Relative pathes are added as a whole, no matter if there is -spf or not.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 27, 2024 at 12:24 UTC (comment 4)

Fixed commit message. Pushed forced.

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Jul 28, 2024 at 8:58 UTC (comment 5)

  • Branch state changed from on review to approved
  • Votes changed from andrew_b to andrew_b zaytsev

I didn't test, but code and description look sound.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 28, 2024 at 11:55 UTC (comment 6)

  • Branch state changed from approved to merged
  • Votes changed from andrew_b zaytsev to committed-master
  • Resolution set to fixed
  • Status changed from accepted to testing

Merged to master: [9b2faec].

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 28, 2024 at 11:57 UTC (comment 7)

  • Status changed from testing to closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: vfs Virtual File System support prio: medium Has the potential to affect progress
Development

No branches or pull requests

2 participants