handle the case where last_accessed_at is null
This commit is contained in:
parent
a084330055
commit
a0f78028cc
1 changed files with 3 additions and 2 deletions
5
db/db.go
5
db/db.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/go-sql-driver/mysql"
|
"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
|
_ "github.com/go-sql-driver/mysql" // blank import for db driver ensures its imported even if its not used
|
||||||
log "github.com/sirupsen/logrus"
|
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
|
// 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 (
|
var (
|
||||||
hash string
|
hash string
|
||||||
streamID uint64
|
streamID uint64
|
||||||
lastAccessedAt time.Time
|
lastAccessedAt null.Time
|
||||||
)
|
)
|
||||||
|
|
||||||
var needsTouch []uint64
|
var needsTouch []uint64
|
||||||
|
@ -218,7 +219,7 @@ WHERE b.is_stored = ? and b.hash IN (` + qt.Qs(len(batch)) + `)`
|
||||||
return errors.Err(err)
|
return errors.Err(err)
|
||||||
}
|
}
|
||||||
exists[hash] = true
|
exists[hash] = true
|
||||||
if s.TrackAccessTime && lastAccessedAt.Before(touchDeadline) {
|
if s.TrackAccessTime && (!lastAccessedAt.Valid || lastAccessedAt.Time.Before(touchDeadline)) {
|
||||||
needsTouch = append(needsTouch, streamID)
|
needsTouch = append(needsTouch, streamID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue