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)
| 1337 | // |
| 1338 | // dir is the start directory, "" for root |
| 1339 | func 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 |
| 1369 | func Sync(ctx context.Context, fdst, fsrc fs.Fs, copyEmptySrcDirs bool) error { |
no test coverage detected
searching dependent graphs…