1
mirror of https://github.com/rclone/rclone synced 2024-12-21 11:45:56 +01:00

vfs: make overwriting directories give an error message - FIXME needs tests

Fixes #8253
This commit is contained in:
Nick Craig-Wood 2024-12-18 17:26:52 +00:00
parent 3fabae87fe
commit b15fd92e26

View File

@ -1145,6 +1145,13 @@ func (d *Dir) Rename(oldName, newName string, destDir *Dir) error {
fs.Errorf(oldPath, "Dir.Rename error: %v", err)
return err
}
// Check to see if we are overwriting something with a directory
_, err := d.vfs.Stat(newPath)
if err == nil {
return EEXIST
} else if err != ENOENT {
return err
}
srcRemote := x.Remote()
dstRemote := newPath
err = operations.DirMove(context.TODO(), d.f, srcRemote, dstRemote)