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

This commit is contained in:
Nick Craig-Wood 2016-12-09 15:41:09 +00:00
parent 48a2e3844d
commit d132dc7640

View file

@ -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 {