-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#14) Fix for archive checksum changing with same content #15
Conversation
Archive contains file header that contains file modification time, whenever this time changes (ie. git checkout) archive checksum changes event if content is the same. There is no way to know what the mtime was so we always set it to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and I apologize for not catching it, if possible could you add an acceptance test where there was a diff due to modified time to ensure this doesn't happen again?
@@ -58,6 +59,8 @@ func (a *ZipArchiver) ArchiveFile(infilename string) error { | |||
} | |||
fh.Name = fi.Name() | |||
fh.Method = zip.Deflate | |||
var mtime time.Time | |||
fh.SetModTime(mtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the docs should just set Modified
directly:
fh.Modified = time.Time{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileInfoHeader
uses SetModTime()
which sets Modified
, ModifiedTime
, ModifiedDate
. Updating only Modified
would still result in changing checksum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the CreateHeader
method overwrites those other deprecated fields as well, it only reads Modified
. But they are all basically ignored because Modified
is a zero value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, you are correct, I see in the internal writing that it does actually write those out :( so much for their deprecation.
Fixes the issue with modified time affecting zip contents
Fixed in #16 (new PR because I added a unit test) |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Archive contains file header that contains file modification time,
whenever this time changes (ie. git checkout) archive checksum changes
event if content is the same. There is no way to know what the mtime was
so we always set it to zero.