1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-22 04:13:14 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Nick Craig-Wood
10dea1ca47 vfs: fix saving from chrome without --vfs-cache-mode writes
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/
2020-07-22 10:22:40 +01:00

View File

@@ -781,9 +781,6 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
return err
}
// Check to see if destination exists
newNode, _ := destDir.stat(newName)
destinationExists := newNode != nil
switch x := oldNode.DirEntry().(type) {
case nil:
if oldFile, ok := oldNode.(*File); ok {
@@ -796,19 +793,6 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
return EPERM
}
case fs.Object:
if destinationExists {
// Can't overwrite dir with file
if newNode.IsDir() {
return EEXIST // EISDIR is POSIX
}
// Try to delete the file
fs.Debugf(newPath, "Dir.Rename removing existing file")
err = newNode.Remove()
if err != nil {
fs.Errorf(newPath, "Dir.Rename error: couldn't delete existing file: %v", err)
return err
}
}
if oldFile, ok := oldNode.(*File); ok {
if err = oldFile.rename(context.TODO(), destDir, newName); err != nil {
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
@@ -820,19 +804,6 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
return err
}
case fs.Directory:
if destinationExists {
// Can't overwrite file with dir
if newNode.IsFile() {
return EEXIST // ENOTDIR is POSIX
}
// Try to delete the existing directory - will succeed only if empty
fs.Debugf(newPath, "Dir.Rename removing existing dir")
err = newNode.Remove()
if err != nil {
fs.Errorf(newPath, "Dir.Rename error: couldn't rmdir existing dir: %v", err)
return err
}
}
features := d.f.Features()
if features.DirMove == nil && features.Move == nil && features.Copy == nil {
err := errors.Errorf("Fs %q can't rename directories (no DirMove, Move or Copy)", d.f)