microsoft / azure-vhd-utils

Azure VHD utilities.
Other
96 stars 41 forks source link

LastModifiedTime compare with .Equal instead of operator #58

Open dctucker opened 5 years ago

dctucker commented 5 years ago

We're seeing more frequent failures when uploading, and this patch seems like it could help based on the error messages we're seeing.

Last modified time of the VHD file in
Azure blob storage (2019-08-12 16:38:18.823769424 +0000 UTC)
and local VHD file (2019-08-12 16:38:18.823769424 +0000 UTC) does not match

(line-breaks edited for clarity)

From https://golang.org/pkg/time/#Time

Note that the Go == operator compares not just the time instant but also the Location and the monotonic clock reading. Therefore, Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values, which can be achieved through use of the UTC or Local method, and that the monotonic clock reading has been stripped by setting t = t.Round(0). In general, prefer t.Equal(u) to t == u, since t.Equal uses the most accurate comparison available and correctly handles the case when only one of its arguments has a monotonic clock reading.