Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

pawbur
Copy link
Contributor

@pawbur pawbur commented Mar 22, 2018

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.

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.
Copy link
Contributor

@paultyng paultyng left a 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)
Copy link
Contributor

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{}

Copy link
Contributor Author

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.

Copy link
Contributor

@paultyng paultyng Mar 23, 2018

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.

Copy link
Contributor

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.

@paultyng
Copy link
Contributor

Fixed in #16 (new PR because I added a unit test)

@paultyng paultyng closed this Mar 23, 2018
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants