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

Method popRenameMap

fs/sync/sync.go:802–838  ·  view source on GitHub ↗

popRenameMap finds the object with hash and pop the first match from renameMap or returns nil if not found.

(hash string, src fs.Object)

Source from the content-addressed store, hash-verified

800// popRenameMap finds the object with hash and pop the first match from
801// renameMap or returns nil if not found.
802func (s *syncCopyMove) popRenameMap(hash string, src fs.Object) (dst fs.Object) {
803 s.renameMapMu.Lock()
804 defer s.renameMapMu.Unlock()
805 dsts, ok := s.renameMap[hash]
806 if ok && len(dsts) > 0 {
807 // Element to remove
808 i := 0
809
810 // If using track renames strategy modtime then we need to check the modtimes here
811 if s.trackRenamesStrategy.modTime() {
812 i = -1
813 srcModTime := src.ModTime(s.ctx)
814 for j, dst := range dsts {
815 dstModTime := dst.ModTime(s.ctx)
816 dt := dstModTime.Sub(srcModTime)
817 if dt < s.modifyWindow && dt > -s.modifyWindow {
818 i = j
819 break
820 }
821 }
822 // If nothing matched then return nil
823 if i < 0 {
824 return nil
825 }
826 }
827
828 // Remove the entry and return it
829 dst = dsts[i]
830 dsts = slices.Delete(dsts, i, i+1)
831 if len(dsts) > 0 {
832 s.renameMap[hash] = dsts
833 } else {
834 delete(s.renameMap, hash)
835 }
836 }
837 return dst
838}
839
840// makeRenameMap builds a map of the destination files by hash that
841// match sizes in the slice of objects in s.renameCheck

Callers 1

tryRenameMethod · 0.95

Calls 5

LockMethod · 0.65
UnlockMethod · 0.65
ModTimeMethod · 0.65
DeleteMethod · 0.65
modTimeMethod · 0.45

Tested by

no test coverage detected