MCPcopy Index your code
hub / github.com/rclone/rclone / makeRenameMap

Method makeRenameMap

fs/sync/sync.go:842–879  ·  view source on GitHub ↗

makeRenameMap builds a map of the destination files by hash that match sizes in the slice of objects in s.renameCheck

()

Source from the content-addressed store, hash-verified

840// makeRenameMap builds a map of the destination files by hash that
841// match sizes in the slice of objects in s.renameCheck
842func (s *syncCopyMove) makeRenameMap() {
843 fs.Infof(s.fdst, "Making map for --track-renames")
844
845 // first make a map of possible sizes we need to check
846 possibleSizes := map[int64]struct{}{}
847 for _, obj := range s.renameCheck {
848 possibleSizes[obj.Size()] = struct{}{}
849 }
850
851 // pump all the dstFiles into in
852 in := make(chan fs.Object, s.ci.Checkers)
853 go s.pumpMapToChan(s.dstFiles, in)
854
855 // now make a map of size,hash for all dstFiles
856 s.renameMap = make(map[string][]fs.Object)
857 var wg sync.WaitGroup
858 wg.Add(s.ci.Checkers)
859 for range s.ci.Checkers {
860 go func() {
861 defer wg.Done()
862 for obj := range in {
863 // only create hash for dst fs.Object if its size could match
864 if _, found := possibleSizes[obj.Size()]; found {
865 tr := accounting.Stats(s.ctx).NewCheckingTransfer(obj, "renaming")
866 hash := s.renameID(obj, s.trackRenamesStrategy, s.modifyWindow)
867
868 if hash != "" {
869 s.pushRenameMap(hash, obj)
870 }
871
872 tr.Done(s.ctx, nil)
873 }
874 }
875 }()
876 }
877 wg.Wait()
878 fs.Infof(s.fdst, "Finished making map for --track-renames")
879}
880
881// tryRename renames an src object when doing track renames if
882// possible, it returns true if the object was renamed.

Callers 1

runMethod · 0.95

Calls 10

pumpMapToChanMethod · 0.95
renameIDMethod · 0.95
pushRenameMapMethod · 0.95
InfofFunction · 0.92
StatsFunction · 0.92
NewCheckingTransferMethod · 0.80
SizeMethod · 0.65
AddMethod · 0.65
WaitMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected