Menu ▾ ▴

#2721 Unable to delete from 7z files in flat view

None
open-rejected
nobody
None
5
5 days ago
5 days ago
Joe Enos
No

When in flat view in 7zfm, if you attempt to delete a directory, you get a confirmation dialog, and no error message, but it doesn't actually do the "delete" (recreate and skip). If you exit flat view, and delete the directory, it works as expected.

To demonstrate, run this PowerShell in an empty directory:

New-Item -ItemType Directory -Path first\inner
New-Item -ItemType File -Path first\inner\hello.txt -Value "Hello"
New-Item -ItemType Directory -Path second\inner
New-Item -ItemType File -Path second\inner\hello.txt -Value "Hello"

& "C:\Program Files\7-zip\7z.exe" a temp.7z .
& "C:\Program Files\7-zip\7zfm.exe" .\temp.7z

Inside of 7zfm, open flat view, then attempt to delete one of the "inner" directories. Nothing actually happens, and the inner directories and files are still there. Change out of flat view, delete one of the "inner" directories, and it does recreate the 7z file as expected, with the inner directory gone.

Discussion

  • Joe Enos

    Joe Enos - 5 days ago

    I'm seeing this in 7-zip 26.04 (x64) on Windows 11

     
  • Igor Pavlov

    Igor Pavlov - 5 days ago

    In flat view, directory items in list do not contain files, because you see files in another items.
    So when you call Delete command , it deletes only directory record itself.
    But then you still see that directory name, because that directory name is prefix of file path.

    Example:
    before deleting you have two records in archive

    dir\
    dir\file1.txt
    

    after deleting you have one record in archive

    dir\file1.txt
    

    but 7-zip FM in flat view still shows dir item because dir is prefix of dir\file1.txt

     
  • Igor Pavlov

    Igor Pavlov - 5 days ago
    • status: open --> open-rejected
    • Group: -->
     
  • Joe Enos

    Joe Enos - 5 days ago

    I can understand how that happens, but I wouldn't expect this to be desired behavior. And even though the 7z file might remove the directory record, if you then extract the 7z file, the folder is there in the results, because of course it has to be in order to have those files inside.

    Compare this to Windows File Explorer search - the results there are similarly flat, but deleting a folder actually deletes it, including its contents.

    If deleting a folder doesn't actually remove its contents from the archive, then why is it even allowed?

    As far as a use case - my specific one is zipping up my "repos" directory for extra external backup - multiple git repos inside of it. Inside this 7z file are several ".git", "bin", "obj", "dist", "node_modules", etc. folders, where I may not want them in my backup. I know it's possible to script out the compression to ignore those in the first place, but for one-off archives, it's easier to just zip up everything and then clean it up - but without flat mode, I'd have to walk the directories one at a time, delete the unwanted folders one at a time, and rebuild the archive over and over until done - with flat view it could all be done together.

     

Log in to post a comment.