in internal/worker/false_positives.go [16:54]
func updateFalsePositives(ctx context.Context, st store.Store) (err error) {
defer derrors.Wrap(&err, "updateFalsePositives")
ctx = event.Start(ctx, "updateFalsePositives")
defer event.End(ctx)
for i := 0; i < len(falsePositives); i += maxTransactionWrites {
j := i + maxTransactionWrites
if j >= len(falsePositives) {
j = len(falsePositives)
}
batch := falsePositives[i:j]
err := st.RunTransaction(ctx, func(ctx context.Context, tx store.Transaction) error {
oldRecords, err := readCVERecords(tx, batch)
if err != nil {
return err
}
for i, cr := range batch {
old := oldRecords[i]
var err error
if old == nil {
err = tx.CreateCVERecord(cr)
} else if old.CommitHash != cr.CommitHash && !old.CommitTime.IsZero() && old.CommitTime.Before(cr.CommitTime) {
// If the false positive data is more recent than what is in
// the store, then update the DB. But ignore records whose
// commit time hasn't been populated.
err = tx.SetCVERecord(cr)
}
if err != nil {
return err
}
}
return nil
})
if err != nil {
return err
}
}
return nil
}