Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vfs: fix edge cases when reading ModTime from file

Nick Craig-Wood358f5a80840c
diff --git a/vfs/file.go b/vfs/file.go
index 40bce2e34..eeecfddb1 100644
--- a/vfs/file.go
+++ b/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