1
mirror of https://github.com/rclone/rclone synced 2024-11-21 22:50:16 +01:00

local: make DirMove return fs.ErrorCantDirMove to allow fallback

Before this change `rclone move localdir /mnt/different-fs` would
error.  Now it falls back to moving individual files, which in turn
falls back to copying individual files across the filesystem boundary.
This commit is contained in:
Nick Craig-Wood 2018-02-26 12:55:05 +00:00
parent 25bbc5d22b
commit 724120d2f3

View File

@ -535,7 +535,20 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
}
// Do the move
return os.Rename(srcPath, dstPath)
err = os.Rename(srcPath, dstPath)
if os.IsNotExist(err) {
// race condition, source was deleted in the meantime
return err
} else if os.IsPermission(err) {
// not enough rights to write to dst
return err
} else if err != nil {
// not quite clear, but probably trying to move directory across file system
// boundaries. Copying might still work.
fs.Errorf(src, "Can't move dir: %v: trying copy", err)
return fs.ErrorCantDirMove
}
return nil
}
// Hashes returns the supported hash sets.