From 4441e012cf66ed8e898e6896e337ace954987a64 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 22 Jul 2020 10:18:52 +0100 Subject: [PATCH] vfs: fix saving from chrome without --vfs-cache-mode writes #4293 Due to Chrome's rather complicated use of file handles when saving files from the download windows, rclone was attempting to truncate a closed file. The file appeared closed due to the handling of 0 length files. This patch removes the check for the file being closed in the WriteFileHandle.Truncate call. This is safe because the only action this method takes is to emit an error message if the file is the wrong size. See: https://forum.rclone.org/t/google-drive-cannot-save-files-directly-from-browser-to-gdrive-mounted-path/17992/ --- vfs/write.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vfs/write.go b/vfs/write.go index 2f5d039d6..bc8c01677 100644 --- a/vfs/write.go +++ b/vfs/write.go @@ -283,11 +283,9 @@ func (fh *WriteFileHandle) Stat() (os.FileInfo, error) { // Truncate file to given size func (fh *WriteFileHandle) Truncate(size int64) (err error) { + // defer log.Trace(fh.remote, "size=%d", size)("err=%v", &err) fh.mu.Lock() defer fh.mu.Unlock() - if fh.closed { - return ECLOSED - } if size != fh.offset { fs.Errorf(fh.remote, "WriteFileHandle: Truncate: Can't change size without --vfs-cache-mode >= writes") return EPERM