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

drive: make DirMove more efficient and complain about moving the root

Nick Craig-Woodd132dc7640a2
diff --git a/drive/drive.go b/drive/drive.go
index 14039a7b1..ec4b57d94 100644
--- a/drive/drive.go
+++ b/drive/drive.go
@@ -771,12 +771,16 @@ func (f *Fs) DirMove(src fs.Fs) error {
}
// Check if destination exists
- f.dirCache.ResetRoot()
- err := f.dirCache.FindRoot(false)
- if err == nil {
+ if f.dirCache.FoundRoot() {
return fs.ErrorDirExists
}
+ // Refuse to move to or from the root
+ if f.root == "" || srcFs.root == "" {
+ fs.Debug(src, "DirMove error: Can't move root")
+ return errors.New("can't move root directory")
+ }
+
// Find ID of parent
leaf, directoryID, err := f.dirCache.FindPath(f.root, true)
if err != nil {