MCPcopy
hub / github.com/rclone/rclone / MoveDir

Function MoveDir

fs/sync/sync.go:1390–1419  ·  view source on GitHub ↗

MoveDir moves fsrc into fdst

(ctx context.Context, fdst, fsrc fs.Fs, deleteEmptySrcDirs bool, copyEmptySrcDirs bool)

Source from the content-addressed store, hash-verified

1388
1389// MoveDir moves fsrc into fdst
1390func MoveDir(ctx context.Context, fdst, fsrc fs.Fs, deleteEmptySrcDirs bool, copyEmptySrcDirs bool) error {
1391 fi := filter.GetConfig(ctx)
1392 if operations.Same(fdst, fsrc) {
1393 fs.Errorf(fdst, "Nothing to do as source and destination are the same")
1394 return nil
1395 }
1396
1397 // First attempt to use DirMover if exists, same Fs and no filters are active
1398 if fdstDirMove := fdst.Features().DirMove; fdstDirMove != nil && operations.SameConfig(fsrc, fdst) && fi.InActive() {
1399 if operations.SkipDestructive(ctx, fdst, "server-side directory move") {
1400 return nil
1401 }
1402 fs.Debugf(fdst, "Using server-side directory move")
1403 err := fdstDirMove(ctx, fsrc, "", "")
1404 switch err {
1405 case fs.ErrorCantDirMove, fs.ErrorDirExists:
1406 fs.Infof(fdst, "Server side directory move failed - fallback to file moves: %v", err)
1407 case nil:
1408 fs.Infof(fdst, "Server side directory move succeeded")
1409 return nil
1410 default:
1411 err = fs.CountError(ctx, err)
1412 fs.Errorf(fdst, "Server side directory move failed: %v", err)
1413 return err
1414 }
1415 }
1416
1417 // Otherwise move the files one by one
1418 return moveDir(ctx, fdst, fsrc, deleteEmptySrcDirs, copyEmptySrcDirs)
1419}

Callers 15

move.goFile · 0.92
moveto.goFile · 0.92
runTestStepMethod · 0.92
rcSyncCopyMoveFunction · 0.85
TestMoveFunction · 0.85
TestTransformFileFunction · 0.85
TestManualTransformFileFunction · 0.85
TestMoveEmptyDirectoriesFunction · 0.85
TestMoveOverSelfFunction · 0.85
testServerSideMoveFunction · 0.85

Calls 10

GetConfigFunction · 0.92
SameFunction · 0.92
ErrorfFunction · 0.92
SameConfigFunction · 0.92
SkipDestructiveFunction · 0.92
DebugfFunction · 0.92
InfofFunction · 0.92
moveDirFunction · 0.85
InActiveMethod · 0.80
FeaturesMethod · 0.65

Tested by 14

runTestStepMethod · 0.74
TestMoveFunction · 0.68
TestTransformFileFunction · 0.68
TestManualTransformFileFunction · 0.68
TestMoveEmptyDirectoriesFunction · 0.68
TestMoveOverSelfFunction · 0.68
testServerSideMoveFunction · 0.68
TestServerSideMoveLocalFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…