MCPcopy
hub / github.com/rclone/rclone / WriteResults

Method WriteResults

cmd/bisync/queue.go:109–173  ·  view source on GitHub ↗

WriteResults is Bisync's LoggerFn

(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error)

Source from the content-addressed store, hash-verified

107
108// WriteResults is Bisync's LoggerFn
109func (b *bisyncRun) WriteResults(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error) {
110 b.queueOpt.lock.Lock()
111 defer b.queueOpt.lock.Unlock()
112
113 opt := operations.GetLoggerOpt(ctx)
114 result := Results{
115 Sigil: sigil,
116 Src: FsPathIfAny(src),
117 Dst: FsPathIfAny(dst),
118 Err: err,
119 Origin: "sync",
120 }
121
122 result.Winner = operations.WinningSide(ctx, sigil, src, dst, err)
123
124 fss := []fs.DirEntry{src, dst}
125 for i, side := range fss {
126
127 result.Name = resultName(result, side, src, dst)
128 result.AltName = altName(result.Name, src, dst)
129 result.IsSrc = i == 0
130 result.IsDst = i == 1
131 result.Flags = "-"
132 if side != nil {
133 result.Size = side.Size()
134 if !b.queueOpt.ignoreListingModtime {
135 result.Modtime = side.ModTime(ctx).In(TZ)
136 }
137 if !b.queueOpt.ignoreListingChecksum {
138 sideObj, ok := side.(fs.ObjectInfo)
139 if ok {
140 result.Hash, _ = sideObj.Hash(ctx, b.getHashType(sideObj.Fs().Name()))
141 result.Hash, _ = b.tryDownloadHash(ctx, sideObj, result.Hash)
142 }
143
144 }
145 }
146 result.IsWinner = result.Winner.Obj == side
147
148 // used during resync only
149 if err == fs.ErrorIsDir {
150 if src != nil {
151 result.Src = src.Remote()
152 result.Name = src.Remote()
153 } else {
154 result.Dst = dst.Remote()
155 result.Name = dst.Remote()
156 }
157 result.Flags = "d"
158 result.Size = -1
159 }
160
161 prettyprint(result, "writing result", fs.LogLevelDebug)
162 if result.Size < 0 && result.Flags != "d" && ((b.queueOpt.queueCI.CheckSum && !b.downloadHashOpt.downloadHash) || b.queueOpt.queueCI.SizeOnly) {
163 b.queueOpt.once.Do(func() {
164 fs.Log(result.Name, Color(terminal.YellowFg, "Files of unknown size (such as Google Docs) do not sync reliably with --checksum or --size-only. Consider using modtime instead (the default) or --drive-skip-gdocs"))
165 })
166 }

Callers

nothing calls this directly

Calls 15

getHashTypeMethod · 0.95
tryDownloadHashMethod · 0.95
GetLoggerOptFunction · 0.92
WinningSideFunction · 0.92
LogFunction · 0.92
ErrorfFunction · 0.92
FsPathIfAnyFunction · 0.85
resultNameFunction · 0.85
altNameFunction · 0.85
prettyprintFunction · 0.85
ColorFunction · 0.85
LockMethod · 0.65

Tested by

no test coverage detected