mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 06:11:43 +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()
|
||||
defer f.mu.RUnlock()
|
||||
|
||||
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
|
||||
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.d.vfs.Opt.NoModTime {
|
||||
return f.d.modTime
|
||||
}
|
||||
|
||||
return f.d.modTime
|
||||
if !f.pendingModTime.IsZero() {
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user