-
Notifications
You must be signed in to change notification settings - Fork 37
Compress-Archive creates a strange directory entry for certain file system configurations #145
Comments
It depends on your definition of "correct". |
Look at uzip. And unzipping as expected:
Perhaps this is a compression algorithm when empty directories are "merged" with a file. |
If your definition of "correct" is "whatever 7zip works with", then yes, it is correct. It is not correct w.r.t. every interop scenario, though. In particular, Though, after taking a closer look, I see that it only has problems with an archive created by Windows PowerShell 5.1, not PowerShell 7.3: it's the kind of the final slash that turns out to be important for it1. Not the flags reported by The logic of creating directory entries only for directories of certain nesting level and with no files still looks kinda weird. Notably, the version from the Footnotes
|
Yes. file-roller, unzip, 7-zip, mc and Far plugins. All of them extract file.zip without errors.I can't test the other archivers. |
Prerequisites
Steps to reproduce
Sometimes,
Compress-Archive
creates a weird directory-like entry in the produced archive. The details I was able to find:Compress-Archive
will create a ZIP entry called<yourDirectoryName>/
not marked as directory according to the output ofzipinfo
So, exact steps to reproduce:
Now, examine the resulting archive using
zipinfo
(I wasn't able to quickly find azipinfo
distribution for Windows, so installedsudo apt install unzip
on my Ubuntu into WSL):The weird path is the first entry:
Notably, the weird entry goes away if I create a file in directory
pt/fspt
:I've seen two kinds of other archives:
drwxr-xr-x
flags instead of-rw----
.At the same time,
[System.IO.Compression.ZipFile]::CreateFromDirectory
works well:$ [System.IO.Compression.ZipFile]::CreateFromDirectory($(Resolve-Path playground), "$(Resolve-Path '.')/file2.zip")
So,
System.IO.Compression.ZipFile]::CreateFromDirectory
doesn't have this problem.For empty directory, it will still create an entry with
-rw----
flags, though, so it is not without problems.Expected behavior
I'd say that
Compress-Archive
should work the same way asSystem.IO.Compression.ZipFile]::CreateFromDirectory
.Actual behavior
Compress-Archive
behaves differently fromSystem.IO.Compression.ZipFile]::CreateFromDirectory
, and in a very strange way that is.Environment data
The issue reproduces in both Windows PowerShell 5.1 and PowerShell 7.3.
The text was updated successfully, but these errors were encountered: