MCPcopy
hub / github.com/rclone/rclone / setResolveDefaults

Method setResolveDefaults

cmd/bisync/resolve.go:80–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78var ConflictLoserList = Opt.ConflictLoser.Help()
79
80func (b *bisyncRun) setResolveDefaults() error {
81 if b.opt.ConflictLoser == ConflictLoserSkip {
82 b.opt.ConflictLoser = ConflictLoserNumber
83 }
84 if b.opt.ConflictSuffixFlag == "" {
85 b.opt.ConflictSuffixFlag = "conflict"
86 }
87 suffixes := strings.Split(b.opt.ConflictSuffixFlag, ",")
88 if len(suffixes) == 1 {
89 b.opt.ConflictSuffix1 = suffixes[0]
90 b.opt.ConflictSuffix2 = suffixes[0]
91 } else if len(suffixes) == 2 {
92 b.opt.ConflictSuffix1 = suffixes[0]
93 b.opt.ConflictSuffix2 = suffixes[1]
94 } else {
95 return fmt.Errorf("--conflict-suffix cannot have more than 2 comma-separated values. Received %v: %v", len(suffixes), suffixes)
96 }
97 // replace glob variables, if any
98 t := time.Now() // capture static time here so it is the same for all files throughout this run
99 b.opt.ConflictSuffix1 = transform.AppyTimeGlobs(b.opt.ConflictSuffix1, t)
100 b.opt.ConflictSuffix2 = transform.AppyTimeGlobs(b.opt.ConflictSuffix2, t)
101
102 // append dot (intentionally allow more than one)
103 b.opt.ConflictSuffix1 = "." + b.opt.ConflictSuffix1
104 b.opt.ConflictSuffix2 = "." + b.opt.ConflictSuffix2
105
106 // checks and warnings
107 if (b.opt.ConflictResolve == PreferNewer || b.opt.ConflictResolve == PreferOlder) && (b.fs1.Precision() == fs.ModTimeNotSupported || b.fs2.Precision() == fs.ModTimeNotSupported) {
108 fs.Logf(nil, Color(terminal.YellowFg, "WARNING: ignoring --conflict-resolve %s as at least one remote does not support modtimes."), b.opt.ConflictResolve.String())
109 b.opt.ConflictResolve = PreferNone
110 } else if (b.opt.ConflictResolve == PreferNewer || b.opt.ConflictResolve == PreferOlder) && !b.opt.Compare.Modtime {
111 fs.Logf(nil, Color(terminal.YellowFg, "WARNING: ignoring --conflict-resolve %s as --compare does not include modtime."), b.opt.ConflictResolve.String())
112 b.opt.ConflictResolve = PreferNone
113 }
114 if (b.opt.ConflictResolve == PreferLarger || b.opt.ConflictResolve == PreferSmaller) && !b.opt.Compare.Size {
115 fs.Logf(nil, Color(terminal.YellowFg, "WARNING: ignoring --conflict-resolve %s as --compare does not include size."), b.opt.ConflictResolve.String())
116 b.opt.ConflictResolve = PreferNone
117 }
118
119 return nil
120}
121
122type (
123 renames map[string]renamesInfo // [originalName]newName (remember the originalName may have an alias)

Callers 1

BisyncFunction · 0.95

Calls 6

AppyTimeGlobsFunction · 0.92
LogfFunction · 0.92
ColorFunction · 0.85
PrecisionMethod · 0.65
StringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected