MCPcopy
hub / github.com/kopia/kopia / compareEntryMetadata

Method compareEntryMetadata

internal/diff/diff.go:242–297  ·  view source on GitHub ↗
(e1, e2 fs.Entry, fullpath string)

Source from the content-addressed store, hash-verified

240}
241
242func (c *Comparer) compareEntryMetadata(e1, e2 fs.Entry, fullpath string) {
243 switch {
244 case e1 == e2: // in particular e1 == nil && e2 == nil
245 return
246 case e1 == nil:
247 c.output(c.statsOnly, "%v does not exist in source directory\n", fullpath)
248 return
249 case e2 == nil:
250 c.output(c.statsOnly, "%v does not exist in destination directory\n", fullpath)
251 return
252 }
253
254 var changed bool
255
256 if m1, m2 := e1.Mode(), e2.Mode(); m1 != m2 {
257 changed = true
258
259 c.output(c.statsOnly, "%v modes differ: %v %v\n", fullpath, m1, m2)
260 }
261
262 if s1, s2 := e1.Size(), e2.Size(); s1 != s2 {
263 changed = true
264
265 c.output(c.statsOnly, "%v sizes differ: %v %v\n", fullpath, s1, s2)
266 }
267
268 if mt1, mt2 := e1.ModTime(), e2.ModTime(); !mt1.Equal(mt2) {
269 changed = true
270
271 c.output(c.statsOnly, "%v modification times differ: %v %v\n", fullpath, mt1, mt2)
272 }
273
274 o1, o2 := e1.Owner(), e2.Owner()
275 if o1.UserID != o2.UserID {
276 changed = true
277
278 c.output(c.statsOnly, "%v owner users differ: %v %v\n", fullpath, o1.UserID, o2.UserID)
279 }
280
281 if o1.GroupID != o2.GroupID {
282 changed = true
283
284 c.output(c.statsOnly, "%v owner groups differ: %v %v\n", fullpath, o1.GroupID, o2.GroupID)
285 }
286
287 _, isDir1 := e1.(fs.Directory)
288 _, isDir2 := e2.(fs.Directory)
289
290 if changed {
291 if isDir1 && isDir2 {
292 c.stats.DirectoryEntries.Modified++
293 } else {
294 c.stats.FileEntries.Modified++
295 }
296 }
297}
298
299func (c *Comparer) compareDirectoryEntries(ctx context.Context, entries1, entries2 []fs.Entry, dirPath string) error {

Callers 1

compareEntryMethod · 0.95

Calls 6

outputMethod · 0.95
EqualMethod · 0.80
OwnerMethod · 0.65
ModeMethod · 0.45
SizeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected