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: Ignore Truncate if called with no readers and already the correct size

Nick Craig-Woodb5f563fb0ffb
diff --git a/vfs/file.go b/vfs/file.go
index eec001b86..a20c6d525 100644
--- a/vfs/file.go
+++ b/vfs/file.go
@@ -601,6 +601,12 @@ func (f *File) Truncate(size int64) (err error) {
}
return err
}
+
+ // If no writers, and size is already correct then all done
+ if f.o.Size() == size {
+ return nil
+ }
+
fs.Debugf(f.o, "Truncating file")
// Otherwise if no writers then truncate the file by opening