mirror of
https://github.com/rclone/rclone.git
synced 2024-11-28 19:24:15 +08:00
vfs: fix edge cases when reading ModTime from file
This fixes the unreliable test TestMount/CacheMode=full/TestFileModTime
This commit is contained in:
parent
9115752679
commit
358f5a8084
20
vfs/file.go
20
vfs/file.go
|
@ -274,18 +274,16 @@ func (f *File) ModTime() (modTime time.Time) {
|
||||||
f.mu.RLock()
|
f.mu.RLock()
|
||||||
defer f.mu.RUnlock()
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
if !f.d.vfs.Opt.NoModTime {
|
if f.d.vfs.Opt.NoModTime {
|
||||||
// if o is nil it isn't valid yet or there are writers, so return the size so far
|
return f.d.modTime
|
||||||
if f.o == nil || len(f.writers) != 0 || f.readWriterClosing {
|
|
||||||
if !f.pendingModTime.IsZero() {
|
|
||||||
return f.pendingModTime
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return f.o.ModTime(context.TODO())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if !f.pendingModTime.IsZero() {
|
||||||
return f.d.modTime
|
return f.pendingModTime
|
||||||
|
}
|
||||||
|
if f.o == nil {
|
||||||
|
return f.d.modTime
|
||||||
|
}
|
||||||
|
return f.o.ModTime(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
// nonNegative returns 0 if i is -ve, i otherwise
|
// nonNegative returns 0 if i is -ve, i otherwise
|
||||||
|
|
Loading…
Reference in New Issue
Block a user