Don't replace caches that are receiving updates (#10834)

Keep caches while they are receiving updates.
Move update code to separate function.
This commit is contained in:
Klaus Post
2020-11-05 07:34:08 -08:00
committed by GitHub
parent d1e1205036
commit bd77f29fc4
2 changed files with 27 additions and 19 deletions

View File

@@ -372,24 +372,7 @@ func (b *bucketMetacache) updateCacheEntry(update metacache) (metacache, error)
logger.Info("updateCacheEntry: bucket %s list id %v not found", b.bucket, update.id)
return update, errFileNotFound
}
existing.lastUpdate = UTCNow()
if existing.status == scanStateStarted && update.status == scanStateSuccess {
existing.ended = UTCNow()
existing.endedCycle = update.endedCycle
}
if existing.status == scanStateStarted && update.status != scanStateStarted {
existing.status = update.status
}
if existing.error == "" && update.error != "" {
existing.error = update.error
existing.status = scanStateError
existing.ended = UTCNow()
}
existing.fileNotFound = existing.fileNotFound || update.fileNotFound
existing.update(update)
b.caches[update.id] = existing
b.updated = true
return existing, nil