Merge pull request #52 from foomo/fix/get-repo-returns-stale-results

fix:  update before getRepo
This commit is contained in:
Daniel Thomas 2025-06-13 23:04:53 +02:00 committed by GitHub
commit e7e5d09f50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -305,6 +305,15 @@ func (r *Repo) update(ctx context.Context) (repoRuntime int64, err error) {
if r.poll { if r.poll {
r.pollVersion = repoURL r.pollVersion = repoURL
} }
// Persist the JSON buffer after successful update
if err := r.history.Add(r.JSONBufferBytes()); err != nil {
r.l.Error("Failed to persist repo after update", zap.Error(err))
metrics.HistoryPersistFailedCounter.WithLabelValues().Inc()
} else {
r.l.Info("Successfully persisted repo after update")
}
return repoRuntime, nil return repoRuntime, nil
} }

View File

@ -285,6 +285,8 @@ func (r *Repo) Update() (updateResponse *responses.Update) {
if historyErr != nil { if historyErr != nil {
r.l.Error("Could not persist current repo in history", zap.Error(historyErr)) r.l.Error("Could not persist current repo in history", zap.Error(historyErr))
metrics.HistoryPersistFailedCounter.WithLabelValues().Inc() metrics.HistoryPersistFailedCounter.WithLabelValues().Inc()
} else {
r.l.Info("Successfully persisted current repo to history")
} }
// add some stats // add some stats
for _, dimension := range r.Directory() { for _, dimension := range r.Directory() {