4c79ed5 caused a regression where a round-trip zip file does not preserve the same ModTime. The reason is because the logic for using extra timestamp is always applied in the Writer no matter what.
This is an issue for when the user doesn't set the ModifiedDate and ModifiedTime fields at all. Causing the Writer to convert a zero MS-DOS timestamp (gibberish) to a Unix timestamp (now gibberish) and back again. The fix is to only apply Extra timestamp only if the MS-DOS timestamp is non-zero.
See:
|
mt := uint32(h.FileHeader.ModTime().Unix()) |
|
var mbuf [9]byte // 2x uint16 + uint8 + uint32 |
|
eb := writeBuf(mbuf[:]) |
|
eb.uint16(exttsExtraId) |
|
eb.uint16(5) // size = uint8 + uint32 |
|
eb.uint8(1) // flags = modtime |
|
eb.uint32(mt) // ModTime |
|
h.Extra = append(h.Extra, mbuf[:]...) |
/cc @mattn
4c79ed5 caused a regression where a round-trip zip file does not preserve the same ModTime. The reason is because the logic for using extra timestamp is always applied in the Writer no matter what.
This is an issue for when the user doesn't set the ModifiedDate and ModifiedTime fields at all. Causing the Writer to convert a zero MS-DOS timestamp (gibberish) to a Unix timestamp (now gibberish) and back again. The fix is to only apply Extra timestamp only if the MS-DOS timestamp is non-zero.
See:
go/src/archive/zip/writer.go
Lines 102 to 109 in 4c79ed5
/cc @mattn