From a0f78028cc08bd2759ca32e31ff00f88c0f8bfe6 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 6 Oct 2020 09:39:43 -0400 Subject: [PATCH] handle the case where last_accessed_at is null --- db/db.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/db.go b/db/db.go index 5720e32..c3bea24 100644 --- a/db/db.go +++ b/db/db.go @@ -12,6 +12,7 @@ import ( "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql" // blank import for db driver ensures its imported even if its not used log "github.com/sirupsen/logrus" + "github.com/volatiletech/null" ) // SdBlob is a special blob that contains information on the rest of the blobs in the stream @@ -170,7 +171,7 @@ func (s *SQL) hasBlobs(hashes []string) (map[string]bool, []uint64, error) { var ( hash string streamID uint64 - lastAccessedAt time.Time + lastAccessedAt null.Time ) var needsTouch []uint64 @@ -218,7 +219,7 @@ WHERE b.is_stored = ? and b.hash IN (` + qt.Qs(len(batch)) + `)` return errors.Err(err) } exists[hash] = true - if s.TrackAccessTime && lastAccessedAt.Before(touchDeadline) { + if s.TrackAccessTime && (!lastAccessedAt.Valid || lastAccessedAt.Time.Before(touchDeadline)) { needsTouch = append(needsTouch, streamID) } }