hdfs: fix incorrect modtime after uploading a file or setting its modtime
SetModTime (which Put and Update also use) kept the caller's full precision modtime in memory while Chtimes sets it with second precision, so until the object was re-read the modtime did not match what a fresh listing would report. This broke wrappers which compare exact modtimes, such as the hasher backend's fingerprint and the VFS cache. Truncate the modtime to second precision to match what the server stores.
This commit is contained in:
1 parent
047e0daae3
commit
0a39aa4d32
1 file changed
+4
-1
@@ -50,7 +50,10 @@ func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.modTime = modTime
|
||||
// Chtimes sets the modtime with second precision so truncate
|
||||
// here too to keep the in-memory modtime identical to the one a
|
||||
// fresh listing returns.
|
||||
o.modTime = modTime.Truncate(time.Second)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user