From e8a13530ae57ac1a5436e633715f33c3c7478230 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sat, 24 Aug 2019 14:37:14 -0700 Subject: [PATCH] upload: fixed time comparison which was sometimes causing re-hashing of contents Thanks to @ntolia for debugging. Fixes #97 --- snapshot/snapshotfs/upload.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/snapshot/snapshotfs/upload.go b/snapshot/snapshotfs/upload.go index 6dcd3b14c..097fa52f8 100644 --- a/snapshot/snapshotfs/upload.go +++ b/snapshot/snapshotfs/upload.go @@ -357,7 +357,7 @@ type uploadWorkItem struct { } func metadataEquals(e1, e2 fs.Entry) bool { - if l, r := e1.ModTime(), e2.ModTime(); l != r { + if l, r := e1.ModTime(), e2.ModTime(); !l.Equal(r) { return false } if l, r := e1.Mode(), e2.Mode(); l != r { @@ -374,11 +374,15 @@ func metadataEquals(e1, e2 fs.Entry) bool { func findCachedEntry(entry fs.Entry, prevEntries []fs.Entries) fs.Entry { for _, e := range prevEntries { - if ent := e.FindByName(entry.Name()); ent != nil && metadataEquals(entry, ent) { - return ent + if ent := e.FindByName(entry.Name()); ent != nil { + if metadataEquals(entry, ent) { + return ent + } + + log.Debugf("found non-matching entry for %v: %v %v %v", entry.Name(), ent.Mode(), ent.Size(), ent.ModTime()) } } - + log.Debugf("could not find cache entry for %v", entry.Name()) return nil }