MCPcopy
hub / github.com/rclone/rclone / setCompareDefaults

Method setCompareDefaults

cmd/bisync/compare.go:31–110  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

29}
30
31func (b *bisyncRun) setCompareDefaults(ctx context.Context) (err error) {
32 ci := fs.GetConfig(ctx)
33
34 // defaults
35 b.opt.Compare.Size = true
36 b.opt.Compare.Modtime = true
37 b.opt.Compare.Checksum = false
38
39 if ci.SizeOnly {
40 b.opt.Compare.Size = true
41 b.opt.Compare.Modtime = false
42 b.opt.Compare.Checksum = false
43 } else if ci.CheckSum && !b.opt.IgnoreListingChecksum {
44 b.opt.Compare.Size = true
45 b.opt.Compare.Modtime = false
46 b.opt.Compare.Checksum = true
47 }
48
49 if ci.IgnoreSize {
50 b.opt.Compare.Size = false
51 }
52
53 err = b.setFromCompareFlag(ctx)
54 if err != nil {
55 return err
56 }
57
58 if b.fs1.Features().SlowHash || b.fs2.Features().SlowHash {
59 b.opt.Compare.SlowHashDetected = true
60 }
61 if b.opt.Compare.Checksum && !b.opt.IgnoreListingChecksum {
62 b.setHashType(ci)
63 }
64
65 if b.opt.Compare.SlowHashSyncOnly && b.opt.Compare.SlowHashDetected && b.opt.Resync {
66 fs.Log(nil, Color(terminal.Dim, "Ignoring checksums during --resync as --slow-hash-sync-only is set."))
67 ci.CheckSum = false
68 // note not setting b.opt.Compare.Checksum = false as we still want to build listings on the non-slow side, if any
69 } else if b.opt.Compare.Checksum && !ci.CheckSum {
70 fs.Log(nil, Color(terminal.YellowFg, "WARNING: Checksums will be compared for deltas but not during sync as --checksum is not set."))
71 }
72 if b.opt.Compare.Modtime && (b.fs1.Precision() == fs.ModTimeNotSupported || b.fs2.Precision() == fs.ModTimeNotSupported) {
73 fs.Log(nil, Color(terminal.YellowFg, "WARNING: Modtime compare was requested but at least one remote does not support it. It is recommended to use --checksum or --size-only instead."))
74 }
75 if (ci.CheckSum || b.opt.Compare.Checksum) && b.opt.IgnoreListingChecksum {
76 if (b.opt.Compare.HashType1 == hash.None || b.opt.Compare.HashType2 == hash.None) && !b.opt.Compare.DownloadHash {
77 fs.Logf(nil, Color(terminal.YellowFg, `WARNING: Checksum compare was requested but at least one remote does not support checksums (or checksums are being ignored) and --ignore-listing-checksum is set.
78 Ignoring Checksums globally and falling back to --compare modtime,size for sync. (Use --compare size or --size-only to ignore modtime). Path1 (%s): %s, Path2 (%s): %s`),
79 b.fs1.String(), b.opt.Compare.HashType1.String(), b.fs2.String(), b.opt.Compare.HashType2.String())
80 b.opt.Compare.Modtime = true
81 b.opt.Compare.Size = true
82 ci.CheckSum = false
83 b.opt.Compare.Checksum = false
84 } else {
85 fs.Log(nil, Color(terminal.YellowFg, "WARNING: Ignoring checksum for deltas as --ignore-listing-checksum is set"))
86 // note: --checksum will still affect the internal sync calls
87 }
88 }

Callers 1

BisyncFunction · 0.95

Calls 11

setFromCompareFlagMethod · 0.95
setHashTypeMethod · 0.95
GetConfigFunction · 0.92
LogFunction · 0.92
LogfFunction · 0.92
InfocFunction · 0.92
ColorFunction · 0.85
prettyprintFunction · 0.85
FeaturesMethod · 0.65
PrecisionMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected