1
mirror of https://github.com/rclone/rclone synced 2024-11-29 07:55:12 +01:00

local: avoid triggering the race detector

This commit is contained in:
Nick Craig-Wood 2017-11-03 16:12:16 +00:00
parent c31556c6d1
commit 73dfa21ba3

View File

@ -767,9 +767,17 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
// setMetadata sets the file info from the os.FileInfo passed in
func (o *Object) setMetadata(info os.FileInfo) {
o.size = info.Size()
o.modTime = info.ModTime()
o.mode = info.Mode()
// Don't overwrite the info if we don't need to
// this avoids upsetting the race detector
if o.size != info.Size() {
o.size = info.Size()
}
if o.modTime != info.ModTime() {
o.modTime = info.ModTime()
}
if o.mode != info.Mode() {
o.mode = info.Mode()
}
}
// Stat a Object into info