This repository was archived by the owner on Jun 30, 2023. It is now read-only.
Commit 50e0590
committed
Fix additional corruption with zips created on linux containing empty directories
This is similar to #36.
Go's zip library has some "interesting" behavior where if you call
zipWriter.CreateHeader with a file header that already contains
extra metadata encoding the last modified time for an empty directory,
it will append the current last modified time to the existing one
stored in the `Extra` field. This leads to corruption similar to #36
where MacOS will refuse to open the zip and `zipinfo -v` will show a
"There are an extra -xxx bytes preceding this file" warning.
I think the Go's library solution to this would be to use CreateRaw,
but we actually do want most of the logic that CreateHeader implements
(see #36 where we switched to CreateHeader). So instead, I just clear
the Extra field in the file header when copying over directories. This
means that directories will have their last modified time reset to the
current date. This is somewhat incorrect, but seems to me like a
reasonable compromise to me.1 parent 73b8540 commit 50e0590
File tree
4 files changed
+11
-1
lines changed- jar
- testdata
4 files changed
+11
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
366 | 368 | | |
367 | 369 | | |
368 | 370 | | |
| |||
Binary file not shown.
Binary file not shown.
0 commit comments