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
s3-about
Nick Craig-Wood 2019-02-12 17:27:04 +00:00
parent 9310c7f3e2
commit b5f563fb0f
1 changed files with 6 additions and 0 deletions

View File

@ -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