MCPcopy
hub / github.com/rclone/rclone / runSyncCopyMove

Function runSyncCopyMove

fs/sync/sync.go:1339–1366  ·  view source on GitHub ↗

Syncs fsrc into fdst If Delete is true then it deletes any files in fdst that aren't in fsrc If DoMove is true then files will be moved instead of copied. dir is the start directory, "" for root

(ctx context.Context, fdst, fsrc fs.Fs, deleteMode fs.DeleteMode, DoMove bool, deleteEmptySrcDirs bool, copyEmptySrcDirs bool, allowOverlap bool)

Source from the content-addressed store, hash-verified

1337//
1338// dir is the start directory, "" for root
1339func runSyncCopyMove(ctx context.Context, fdst, fsrc fs.Fs, deleteMode fs.DeleteMode, DoMove bool, deleteEmptySrcDirs bool, copyEmptySrcDirs bool, allowOverlap bool) error {
1340 ci := fs.GetConfig(ctx)
1341 if deleteMode != fs.DeleteModeOff && DoMove {
1342 return fserrors.FatalError(errors.New("can't delete and move at the same time"))
1343 }
1344 // Run an extra pass to delete only
1345 if deleteMode == fs.DeleteModeBefore {
1346 if ci.TrackRenames {
1347 return fserrors.FatalError(errors.New("can't use --delete-before with --track-renames"))
1348 }
1349 // only delete stuff during in this pass
1350 do, err := newSyncCopyMove(ctx, fdst, fsrc, fs.DeleteModeOnly, false, deleteEmptySrcDirs, copyEmptySrcDirs, allowOverlap)
1351 if err != nil {
1352 return err
1353 }
1354 err = do.run()
1355 if err != nil {
1356 return err
1357 }
1358 // Next pass does a copy only
1359 deleteMode = fs.DeleteModeOff
1360 }
1361 do, err := newSyncCopyMove(ctx, fdst, fsrc, deleteMode, DoMove, deleteEmptySrcDirs, copyEmptySrcDirs, allowOverlap)
1362 if err != nil {
1363 return err
1364 }
1365 return do.run()
1366}
1367
1368// Sync fsrc into fdst
1369func Sync(ctx context.Context, fdst, fsrc fs.Fs, copyEmptySrcDirs bool) error {

Callers 4

SyncFunction · 0.85
CopyDirFunction · 0.85
moveDirFunction · 0.85
TransformFunction · 0.85

Calls 4

GetConfigFunction · 0.92
FatalErrorFunction · 0.92
newSyncCopyMoveFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…