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 {