MCPcopy
hub / github.com/rclone/rclone / run

Method run

fs/sync/sync.go:923–1026  ·  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

()

Source from the content-addressed store, hash-verified

921//
922// dir is the start directory, "" for root
923func (s *syncCopyMove) run() error {
924 if operations.Same(s.fdst, s.fsrc) && !s.allowOverlap {
925 fs.Errorf(s.fdst, "Nothing to do as source and destination are the same")
926 return nil
927 }
928
929 // Start background checking and transferring pipeline
930 s.startCheckers()
931 s.startRenamers()
932 if !s.checkFirst {
933 s.startTransfers()
934 }
935 s.startDeleters()
936 s.dstFiles = make(map[string]fs.Object)
937
938 s.startTrackRenames()
939
940 // set up a march over fdst and fsrc
941 m := &march.March{
942 Ctx: s.inCtx,
943 Fdst: s.fdst,
944 Fsrc: s.fsrc,
945 Dir: s.dir,
946 NoTraverse: s.noTraverse,
947 Callback: s,
948 DstIncludeAll: s.fi.Opt.DeleteExcluded,
949 NoCheckDest: s.noCheckDest,
950 NoUnicodeNormalization: s.noUnicodeNormalization,
951 }
952 s.processError(m.Run(s.ctx))
953
954 s.stopTrackRenames()
955 if s.trackRenames {
956 // Build the map of the remaining dstFiles by hash
957 s.makeRenameMap()
958 // Attempt renames for all the files which don't have a matching dst
959 for _, src := range s.renameCheck {
960 ok := s.toBeRenamed.Put(s.inCtx, fs.ObjectPair{Src: src, Dst: nil})
961 if !ok {
962 break
963 }
964 }
965 }
966
967 // Stop background checking and transferring pipeline
968 s.stopCheckers()
969 if s.checkFirst {
970 fs.Infof(s.fdst, "Checks finished, now starting transfers")
971 s.startTransfers()
972 }
973 s.stopRenamers()
974 s.stopTransfers()
975 s.stopDeleters()
976
977 // Delete files after
978 if s.deleteMode == fs.DeleteModeAfter {
979 if s.currentError() != nil && !s.ci.IgnoreErrors {
980 fs.Errorf(s.fdst, "%v", fs.ErrorNotDeleting)

Callers 1

runSyncCopyMoveFunction · 0.45

Calls 15

startCheckersMethod · 0.95
startRenamersMethod · 0.95
startTransfersMethod · 0.95
startDeletersMethod · 0.95
startTrackRenamesMethod · 0.95
processErrorMethod · 0.95
RunMethod · 0.95
stopTrackRenamesMethod · 0.95
makeRenameMapMethod · 0.95
stopCheckersMethod · 0.95
stopRenamersMethod · 0.95
stopTransfersMethod · 0.95

Tested by

no test coverage detected