fix(quick-13): resolve lint issues in main source files
- Fix errcheck for db.Close() in testhelper.go - Fix errcheck, nlreturn, wsl, gofumpt issues in genevents/main.go - Fix gofumpt and wsl issues in library.go
This commit is contained in:
@@ -229,6 +229,7 @@ func (l *Library) Scan() (*ScanMetrics, error) {
|
||||
"count", len(existingFiles),
|
||||
"library-directory", l.conf.DirectoryPath,
|
||||
)
|
||||
|
||||
workChan := make(chan scanWork, 100)
|
||||
resultChan := make(chan importResult, 100)
|
||||
|
||||
@@ -531,10 +532,14 @@ func (l *Library) Scan() (*ScanMetrics, error) {
|
||||
// point so it is safe to close.
|
||||
thumbStart := time.Now()
|
||||
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanProgress,
|
||||
ScanProgress{Phase: "thumbnails", Total: totalFiles,
|
||||
Processed: a + s + u, Added: a, Skipped: s, Updated: u},
|
||||
)
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanProgress, ScanProgress{
|
||||
Phase: "thumbnails",
|
||||
Total: totalFiles,
|
||||
Processed: a + s + u,
|
||||
Added: a,
|
||||
Skipped: s,
|
||||
Updated: u,
|
||||
})
|
||||
|
||||
close(thumbChan)
|
||||
thumbWg.Wait()
|
||||
@@ -542,10 +547,10 @@ func (l *Library) Scan() (*ScanMetrics, error) {
|
||||
metrics.ThumbnailWallClock = time.Since(thumbStart)
|
||||
|
||||
// --- Phase 5: orphan cleanup ---
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanProgress,
|
||||
ScanProgress{Phase: "orphans", Total: totalFiles,
|
||||
Processed: a + s + u, Added: a, Skipped: s, Updated: u},
|
||||
)
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanProgress, ScanProgress{
|
||||
Phase: "orphans", Total: totalFiles,
|
||||
Processed: a + s + u, Added: a, Skipped: s, Updated: u,
|
||||
})
|
||||
|
||||
orphanStart := time.Now()
|
||||
|
||||
|
||||
@@ -396,7 +396,10 @@ func TestCachedLinkArtist(t *testing.T) {
|
||||
lib.cachedLinkArtist(q, cache, metrics, "Queen", ac.ID)
|
||||
|
||||
if len(cache.linkedCredits) != 1 {
|
||||
t.Errorf("linkedCredits after duplicate = %d, want 1 (should skip)", len(cache.linkedCredits))
|
||||
t.Errorf(
|
||||
"linkedCredits after duplicate = %d, want 1 (should skip)",
|
||||
len(cache.linkedCredits),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,6 +539,7 @@ func TestResolveReleaseGroup(t *testing.T) {
|
||||
// Cache key is composite: "albumName\x00artistCreditID".
|
||||
cacheKey := fmt.Sprintf("%s\x00%d", "A Night at the Opera", ac.ID)
|
||||
cachedRG := cache.releaseGroups[cacheKey]
|
||||
|
||||
if !cachedRG.CoverArtID.Valid {
|
||||
t.Error("expected CoverArtID to be set after update")
|
||||
}
|
||||
@@ -616,7 +620,9 @@ func TestOrphanDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
// Add FTS search index entry.
|
||||
if err := db.InsertSearchIndex(af.ID, "/music/test.mp3", "Test Song", "Test Artist", ""); err != nil {
|
||||
if err := db.InsertSearchIndex(
|
||||
af.ID, "/music/test.mp3", "Test Song", "Test Artist", "",
|
||||
); err != nil {
|
||||
t.Fatalf("insert search index: %v", err)
|
||||
}
|
||||
|
||||
@@ -651,11 +657,12 @@ func TestOrphanDeletion(t *testing.T) {
|
||||
// become stale but harmless (they reference a non-existent
|
||||
// audio_file ID, so JOINs return no results).
|
||||
// ClearSearchIndex (used during full rescan) handles bulk cleanup.
|
||||
// DeleteSearchIndex on contentless FTS5 is expected to error.
|
||||
// Not a fatal error — documents the contentless FTS5 limitation.
|
||||
err = db.DeleteSearchIndex(af.ID)
|
||||
if err == nil {
|
||||
t.Log("DeleteSearchIndex succeeded (unexpected for contentless FTS5)")
|
||||
}
|
||||
// Not a fatal error — documents the contentless FTS5 limitation.
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -705,7 +712,10 @@ func TestEntityCache_EmptyFields(t *testing.T) {
|
||||
}
|
||||
|
||||
if albumACID.Int64 != trackAC.ID {
|
||||
t.Errorf("empty AlbumArtist should reuse track credit: got %d, want %d", albumACID.Int64, trackAC.ID)
|
||||
t.Errorf(
|
||||
"empty AlbumArtist should reuse track credit: got %d, want %d",
|
||||
albumACID.Int64, trackAC.ID,
|
||||
)
|
||||
}
|
||||
|
||||
// resolveAlbumArtistCredit when AlbumArtist matches Artist also reuses.
|
||||
@@ -716,6 +726,9 @@ func TestEntityCache_EmptyFields(t *testing.T) {
|
||||
|
||||
sameACID := lib.resolveAlbumArtistCredit(q, cache, metrics, sameTags, trackAC.ID)
|
||||
if sameACID.Int64 != trackAC.ID {
|
||||
t.Errorf("matching AlbumArtist should reuse track credit: got %d, want %d", sameACID.Int64, trackAC.ID)
|
||||
t.Errorf(
|
||||
"matching AlbumArtist should reuse track credit: got %d, want %d",
|
||||
sameACID.Int64, trackAC.ID,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user