From b5f563fb0ffb5ea2f88a1700715559152a9dc52f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 12 Feb 2019 17:27:04 +0000 Subject: [PATCH] vfs: Ignore Truncate if called with no readers and already the correct size This fixes FreeBSD which seems to call SetAttr with a size even on read only files. This is probably a bug in the FreeBSD FUSE implementation as it happens with mount and cmount. See: https://forum.rclone.org/t/freebsd-question/8662/12 --- vfs/file.go | 6 ++++++ 1 file changed, 6 insertions(+) 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