MCPcopy
hub / github.com/rclone/rclone / renameID

Method renameID

fs/sync/sync.go:762–791  ·  view source on GitHub ↗

renameID makes a string with the size and the other identifiers of the requested rename strategies it may return an empty string in which case no hash could be made

(obj fs.Object, renamesStrategy trackRenamesStrategy, precision time.Duration)

Source from the content-addressed store, hash-verified

760//
761// it may return an empty string in which case no hash could be made
762func (s *syncCopyMove) renameID(obj fs.Object, renamesStrategy trackRenamesStrategy, precision time.Duration) string {
763 var builder strings.Builder
764
765 fmt.Fprintf(&builder, "%d", obj.Size())
766
767 if renamesStrategy.hash() {
768 var err error
769 hash, err := obj.Hash(s.ctx, s.commonHash)
770 if err != nil {
771 fs.Debugf(obj, "Hash failed: %v", err)
772 return ""
773 }
774 if hash == "" {
775 return ""
776 }
777
778 builder.WriteRune(',')
779 builder.WriteString(hash)
780 }
781
782 // for renamesStrategy.modTime() we don't add to the hash but we check the times in
783 // popRenameMap
784
785 if renamesStrategy.leaf() {
786 builder.WriteRune(',')
787 builder.WriteString(path.Base(obj.Remote()))
788 }
789
790 return builder.String()
791}
792
793// pushRenameMap adds the object with hash to the rename map
794func (s *syncCopyMove) pushRenameMap(hash string, obj fs.Object) {

Callers 2

makeRenameMapMethod · 0.95
tryRenameMethod · 0.95

Calls 9

DebugfFunction · 0.92
hashMethod · 0.80
leafMethod · 0.80
BaseMethod · 0.80
SizeMethod · 0.65
HashMethod · 0.65
WriteStringMethod · 0.65
RemoteMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected