From 9198bde34ad1b75060773de32ff3bb111b9d6ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deluan=20Quint=C3=A3o?= Date: Sun, 6 Sep 2026 13:40:43 -0400 Subject: [PATCH] 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. --- scanner/scanner_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go index 00f91699d..8542b3ac6 100644 --- a/scanner/scanner_test.go +++ b/scanner/scanner_test.go @@ -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()