archive/zip: Create()
does not overwrite duplicate filenames, leading to unnecessary bloating of the resulting ZIP file
#66810
Labels
Documentation
help wanted
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Go version
go version go1.22.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I called
Create()
with the same filename multiple times. https://go.dev/play/p/hu1QDLK7BnTWhat did you see happen?
I have noticed that when using
Create()
with the same filename multiple times, the resulting ZIP file becomes increasingly larger. This becomes a problem when trying to extract the files using common unzip utilities such as the default archiver on MacOS or theunzip
command. These utilities are unable to handle duplicate filenames and will only output a single file when there are multiple files with the same name in a ZIP file. This is confusing and inefficient at the same time.What did you expect to see?
In my opinion, there are two potential solutions to this issue. First,
Create()
could prevent multiple calls with the same filename. Alternatively, it could overwrite the previously added file with the same name using the new file content, rather than simply appending it. However, I believe this may cause unnecessary overhead. In such a scenario, adding a caution to the documentation ofCreate()
would be beneficial for users.The text was updated successfully, but these errors were encountered: