mirror of
https://github.com/rclone/rclone.git
synced 2026-01-01 08:03:26 +00:00
Add srcRemote and dstRemote parameters to DirMove #954
This commit is contained in:
@@ -563,19 +563,22 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
||||
return dstObj, nil
|
||||
}
|
||||
|
||||
// DirMove moves src to this remote using server side move operations.
|
||||
// DirMove moves src, srcRemote to this remote at dstRemote
|
||||
// using server side move operations.
|
||||
//
|
||||
// Will only be called if src.Fs().Name() == f.Name()
|
||||
//
|
||||
// If it isn't possible then return fs.ErrorCantDirMove
|
||||
//
|
||||
// If destination exists then return fs.ErrorDirExists
|
||||
func (f *Fs) DirMove(src fs.Fs) error {
|
||||
func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
|
||||
srcFs, ok := src.(*Fs)
|
||||
if !ok {
|
||||
fs.Debugf(srcFs, "Can't move directory - not same remote type")
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
srcPath := path.Join(srcFs.slashRoot, srcRemote)
|
||||
dstPath := path.Join(f.slashRoot, dstRemote)
|
||||
|
||||
// Check if destination exists
|
||||
entry, err := f.db.Metadata(f.slashRoot, false, false, "", "", metadataLimit)
|
||||
@@ -583,8 +586,11 @@ func (f *Fs) DirMove(src fs.Fs) error {
|
||||
return fs.ErrorDirExists
|
||||
}
|
||||
|
||||
// Make sure the parent directory exists
|
||||
// ...apparently not necessary
|
||||
|
||||
// Do the move
|
||||
_, err = f.db.Move(srcFs.slashRoot, f.slashRoot)
|
||||
_, err = f.db.Move(srcPath, dstPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "MoveDir failed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user