MCPcopy
hub / github.com/rclone/rclone / DirMove

Method DirMove

backend/mega/mega.go:846–880  ·  view source on GitHub ↗

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

(ctx context.Context, src fs.Fs, srcRemote, dstRemote string)

Source from the content-addressed store, hash-verified

844//
845// If destination exists then return fs.ErrorDirExists
846func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error {
847 dstFs := f
848 srcFs, ok := src.(*Fs)
849 if !ok {
850 fs.Debugf(srcFs, "Can't move directory - not same remote type")
851 return fs.ErrorCantDirMove
852 }
853
854 // find the source
855 info, err := srcFs.lookupDir(ctx, srcRemote)
856 if err != nil {
857 return err
858 }
859
860 // check the destination doesn't exist
861 _, err = dstFs.lookupDir(ctx, dstRemote)
862 if err == nil {
863 return fs.ErrorDirExists
864 } else if err != fs.ErrorDirNotFound {
865 return fmt.Errorf("DirMove error while checking dest directory: %w", err)
866 }
867
868 // Do the move
869 err = f.move(ctx, dstRemote, srcFs, srcRemote, info)
870 if err != nil {
871 return err
872 }
873
874 // Clear src if it was the root
875 if srcRemote == "" {
876 srcFs.clearRoot()
877 }
878
879 return nil
880}
881
882// DirCacheFlush an optional interface to flush internal directory cache
883func (f *Fs) DirCacheFlush() {

Callers

nothing calls this directly

Calls 5

moveMethod · 0.95
DebugfFunction · 0.92
clearRootMethod · 0.80
lookupDirMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected