From d132dc7640a2177681372611b8c90b2593d59391 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 9 Dec 2016 15:41:09 +0000 Subject: [PATCH] drive: make DirMove more efficient and complain about moving the root --- drive/drive.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 {