golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.86k stars 17.52k forks source link

archive/zip: extra Extra fields when repacking zip file #61572

Open rsc opened 1 year ago

rsc commented 1 year ago

If you use zip.(*Writer).CreateHeader (for example using a header from a zip file you are copying), CreateHeader encodes fh.Modified into fh.Extra even if fh.Extra already contains a modified time. You get an Extra with an extra extTimeExtraID entry. If there is already a extTimeExtraID entry in Extra, we shold not add an extra extTimeExtraID.

gopherbot commented 1 year ago

Change https://go.dev/cl/513437 mentions this issue: archive/zip: ignore modified time if extended timestamp extra field exists

AlexanderYastrebov commented 1 year ago

If there is already a extTimeExtraID entry in Extra, we shold not add an extra extTimeExtraID.

Should it ignore fh.Modified or overwrite existing extra field?

gopherbot commented 1 year ago

Change https://go.dev/cl/513836 mentions this issue: archive/zip: update extended timestamp field if exists

AlexanderYastrebov commented 1 year ago

Should it ignore fh.Modified or overwrite existing extra field?

I think it should update existing extended timestamp field otherwise there is no way to do it without digging into extra fields. Created https://github.com/golang/go/pull/61622 that implements this.