Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

local: make DirMove return fs.ErrorCantDirMove to allow fallback

Nick Craig-Wood724120d2f3a4
diff --git a/backend/local/local.go b/backend/local/local.go
index f01493a3b..0b70c0dc8 100644
--- a/backend/local/local.go
+++ b/backend/local/local.go
@@ -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.