WriteResults is Bisync's LoggerFn
(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error)
| 107 | |
| 108 | // WriteResults is Bisync's LoggerFn |
| 109 | func (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 | } |
nothing calls this directly
no test coverage detected