fix(cli): keep the re-enqueue warning when a backfill is already running

A stale stored fingerprint with items already queued is the worst state the
system can be in: a second full re-enqueue is pending on top of the one running.
The line carried the weakest wording of the three, and was untested.
This commit is contained in:
Deluan 2026-08-14 14:47:54 -04:00
commit b276e8aceb
2 changed files with 16 additions and 6 deletions

View file

@ -232,15 +232,16 @@ func formatStatus(rep statusReport) string {
// backfillState leads with the queued backlog: by the time anyone runs this, backfill has usually
// already stored the new fingerprint, and "up to date" would bury the flood it is still working through.
func backfillState(rep statusReport) string {
changed := "fingerprint up to date"
if rep.stored != rep.current {
changed = "fingerprint changed"
}
// A stale stored fingerprint means backfill has not recorded the new one, so the flood repeats.
pending := "fingerprint changed — every artist, album, playlist and radio will be re-enqueued on the next startup"
if n := rep.backfillQueued(); n > 0 {
return fmt.Sprintf("backfill running: %d items queued (%s)", n, changed)
if rep.stored != rep.current {
return fmt.Sprintf("backfill running: %d items queued, and %s", n, pending)
}
return fmt.Sprintf("backfill running: %d items queued (fingerprint up to date)", n)
}
if rep.stored != rep.current {
return "fingerprint changed — every artist, album, playlist and radio will be re-enqueued on the next startup"
return pending
}
return "up to date"
}

View file

@ -587,6 +587,15 @@ var _ = Describe("formatStatus", func() {
Expect(out).To(ContainSubstring("fingerprint up to date"))
})
It("keeps the re-enqueue warning while a backfill is already running", func() {
rep.stored = "older"
out := block(formatStatus(rep), "Backfill")
Expect(out).To(MatchRegexp(`State:\s+backfill running: 2 items queued`))
Expect(out).To(ContainSubstring("re-enqueued"),
"the stored fingerprint is still stale, so a second full re-enqueue is pending on top of this one")
})
It("reports up to date only once the backfill has drained", func() {
rep.queue = []model.ArtworkQueueStat{{ItemKind: "al", Priority: model.ArtworkPriorityScan, Count: 1}}