test(scanner): fix Windows flake in the quick-scan artist image spec (#6093)

The spec asserted on artistID("Kraftwerk") and intermittently found zero artists
on Windows. The scan did import the artist; it was then made invisible.

RefreshStats selects touched artists with a strict artist.updated_at >
library.last_scan_at (persistence/artist_repository.go:466). Windows' wall clock
has ~15ms granularity, so a new artist written by a quick scan can land in the
same tick as the previous scan's last_scan_at and be excluded. Its
library_artist.stats then stays at the '{}' default and the unscoped cleanup
DELETE removes the row, after which selectArtist's INNER JOIN on library_artist
hides the artist from GetAll.

Backdate last_scan_at before the scan so the comparison is unambiguous, matching
the fix already applied to the search_normalized spec below it.
This commit is contained in:
Deluan Quintão 2026-09-06 13:40:43 -04:00 • committed by GitHub
commit 9198bde34a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -387,6 +387,11 @@ var _ = Describe("Scanner", Ordered, func() {
files := fsys.MapFS
files["Kraftwerk/Autobahn/01 - Autobahn.mp3"] = kraftwerk(track(1, "Autobahn"))
fsys.SetFiles(files)
// Backdate the previous scan so this one's new artists are unambiguously newer:
// RefreshStats picks touched artists with a strict artist.updated_at >
// library.last_scan_at, and Windows' coarse clock can put both in one tick.
_, err := db.Db().ExecContext(ctx, "UPDATE library SET last_scan_at = ?", time.Now().Add(-time.Hour))
Expect(err).ToNot(HaveOccurred())
Expect(runScanner(ctx, false)).To(Succeed())
resolveQueuedArtwork()