mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 07:51:24 +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
14
vfs/file.go
14
vfs/file.go
|
@ -274,19 +274,17 @@ 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.d.vfs.Opt.NoModTime {
|
||||
return f.d.modTime
|
||||
}
|
||||
if !f.pendingModTime.IsZero() {
|
||||
return f.pendingModTime
|
||||
}
|
||||
} else {
|
||||
return f.o.ModTime(context.TODO())
|
||||
}
|
||||
}
|
||||
|
||||
if f.o == nil {
|
||||
return f.d.modTime
|
||||
}
|
||||
return f.o.ModTime(context.TODO())
|
||||
}
|
||||
|
||||
// nonNegative returns 0 if i is -ve, i otherwise
|
||||
func nonNegative(i int64) int64 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user