vfs: fix open file renaming on drive when using --vfs-cache-mode writes
Before this change, when uploading files from the VFS cache which were pending a rename, rclone would use the new path of the object when specifiying the destination remote. This didn't cause a problem with most backends as the subsequent rename did nothing, however with the drive backend, since it updates objects, the incorrect Remote was embedded in the object. This caused the rename to apparently succeed but the object be at the wrong location. The fix for this was to make sure we upload to the path stored in the object if available. This problem was spotted by the new rename tests for the VFS layer.
This commit is contained in:
+6
-1
@@ -284,7 +284,12 @@ func (fh *RWFileHandle) flushWrites(closeFile bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
o, err := copyObj(fh.d.vfs.f, fh.file.getObject(), fh.file.Path(), cacheObj)
|
||||
objPath := fh.file.Path()
|
||||
objOld := fh.file.getObject()
|
||||
if objOld != nil {
|
||||
objPath = objOld.Remote() // use the path of the actual object if available
|
||||
}
|
||||
o, err := copyObj(fh.d.vfs.f, objOld, objPath, cacheObj)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "failed to transfer file from cache to remote")
|
||||
fs.Errorf(fh.logPrefix(), "%v", err)
|
||||
|
||||
Reference in New Issue
Block a user