diff --git a/go_backend/audio_metadata.go b/go_backend/audio_metadata.go index f632a0e7..353a537c 100644 --- a/go_backend/audio_metadata.go +++ b/go_backend/audio_metadata.go @@ -99,11 +99,6 @@ func readID3TagsAndCover(filePath string, includeCover bool) (*AudioMetadata, [] return metadata, cover, mime, nil } -func readID3v2(file *os.File) (*AudioMetadata, error) { - metadata, _, _, err := readID3v2WithCover(file, false) - return metadata, err -} - func parseID3v22Frames(data []byte, metadata *AudioMetadata, tagUnsync bool) { parseID3Frames(data, metadata, 2, tagUnsync) } diff --git a/go_backend/extension_lifecycle_signed_session_timeout_test.go b/go_backend/extension_lifecycle_signed_session_timeout_test.go index 833c460f..8119f0de 100644 --- a/go_backend/extension_lifecycle_signed_session_timeout_test.go +++ b/go_backend/extension_lifecycle_signed_session_timeout_test.go @@ -159,7 +159,7 @@ func TestSignedSessionGrantRetryHonorsCancellationAndReleasesCoordinator(t *test lockAcquired := make(chan struct{}) go func() { coordinator.mu.Lock() - coordinator.mu.Unlock() + defer coordinator.mu.Unlock() close(lockAcquired) }() select { diff --git a/go_backend/extension_runtime.go b/go_backend/extension_runtime.go index c3a969a3..78e0a219 100644 --- a/go_backend/extension_runtime.go +++ b/go_backend/extension_runtime.go @@ -477,13 +477,6 @@ func (w *stallWatchdog) stop() { w.cancel() } -// stallError is returned when the watchdog fires. The message is deliberately -// free of "cancel" and worded to classify as retryable network failure, so the -// fallback layer retries instead of treating it as a user cancellation. -func (r *extensionRuntime) stallError() goja.Value { - return r.jsError("download stalled: no data received for %ds (network timeout)", int(downloadStallTimeout.Seconds())) -} - func newExtensionHTTPClient(ext *loadedExtension, jar http.CookieJar, timeout time.Duration, compressResponses bool) *http.Client { // Extension sandbox enforces HTTPS-only domains. Do not apply global // allow_http scheme downgrade here, because some extension APIs (e.g. diff --git a/go_backend/extension_runtime_stall_test.go b/go_backend/extension_runtime_stall_test.go index ec1694af..80ec4271 100644 --- a/go_backend/extension_runtime_stall_test.go +++ b/go_backend/extension_runtime_stall_test.go @@ -2,6 +2,7 @@ package gobackend import ( "context" + "errors" "net/http" "net/http/httptest" "testing" @@ -45,8 +46,8 @@ func TestStallWatchdogCancelsOnNoData(t *testing.T) { break } } - if readErr == nil { - t.Fatal("expected read error from stall cancel") + if !errors.Is(readErr, context.Canceled) { + t.Fatalf("read error = %v, want watchdog context cancellation", readErr) } if !wd.stalled.Load() { t.Fatalf("watchdog did not mark stalled; err=%v", readErr) diff --git a/go_backend/extension_runtime_storage.go b/go_backend/extension_runtime_storage.go index b10363a2..c74448a8 100644 --- a/go_backend/extension_runtime_storage.go +++ b/go_backend/extension_runtime_storage.go @@ -175,23 +175,6 @@ func readJSONMapFile(path string) (map[string]any, error) { return result, nil } -func (r *extensionRuntime) refreshStorage() error { - path := r.getStoragePath() - fileMu := extensionFileMu(path) - fileMu.Lock() - snapshot, err := readCachedJSONMapLocked(path, func() (map[string]any, error) { - return readJSONMapFile(path) - }) - fileMu.Unlock() - if err != nil { - return err - } - r.storageMu.Lock() - r.storageCache = snapshot - r.storageMu.Unlock() - return nil -} - func (r *extensionRuntime) mutateStorage(mutate func(map[string]any) bool) error { r.storageMu.RLock() closed := r.storageClosed diff --git a/go_backend/extension_runtime_storage_test.go b/go_backend/extension_runtime_storage_test.go index fa0a4f1b..75df73d5 100644 --- a/go_backend/extension_runtime_storage_test.go +++ b/go_backend/extension_runtime_storage_test.go @@ -167,7 +167,8 @@ func TestExtensionRuntimeStorageConcurrentRuntimesMergeWrites(t *testing.T) { done <- result.ToBoolean() }() close(start) - if !<-done || !<-done { + firstSucceeded, secondSucceeded := <-done, <-done + if !firstSucceeded || !secondSucceeded { t.Fatal("concurrent storage write failed") } diff --git a/go_backend/extension_signed_session.go b/go_backend/extension_signed_session.go index cdc82b8f..bf84c42b 100644 --- a/go_backend/extension_signed_session.go +++ b/go_backend/extension_signed_session.go @@ -1249,16 +1249,6 @@ func (r *extensionRuntime) refreshSignedSession(config SignedSessionConfig, reco return nil } -func (r *extensionRuntime) startSignedSessionVerification(config SignedSessionConfig, reason string) (string, error) { - coordinator, err := r.signedSessionCoordinator(config) - if err != nil { - return "", err - } - coordinator.mu.Lock() - defer coordinator.mu.Unlock() - return r.startSignedSessionVerificationLocked(config, coordinator, reason) -} - func (r *extensionRuntime) startSignedSessionVerificationLocked( config SignedSessionConfig, coordinator *signedSessionCoordinator, diff --git a/go_backend/extension_signed_session_test.go b/go_backend/extension_signed_session_test.go index 495451d9..8826211a 100644 --- a/go_backend/extension_signed_session_test.go +++ b/go_backend/extension_signed_session_test.go @@ -2132,7 +2132,7 @@ func TestRefreshSignedSessionCoalescesWithoutHoldingCoordinatorMutex(t *testing. mutexAvailable := make(chan struct{}) go func() { coordinator.mu.Lock() - coordinator.mu.Unlock() + defer coordinator.mu.Unlock() close(mutexAvailable) }() select { diff --git a/go_backend/library_scan_formats.go b/go_backend/library_scan_formats.go index f1d9ddd0..76814781 100644 --- a/go_backend/library_scan_formats.go +++ b/go_backend/library_scan_formats.go @@ -7,10 +7,6 @@ import ( "strings" ) -func scanAudioFileWithKnownModTime(filePath, scanTime string, knownModTime int64) (*LibraryScanResult, error) { - return scanAudioFileWithKnownModTimeAndDisplayNameAndCoverCacheKey(filePath, "", "", scanTime, knownModTime) -} - func scanAudioFileWithKnownModTimeAndDisplayNameAndCoverCacheKey(filePath, displayNameHint, coverCacheKey, scanTime string, knownModTime int64) (*LibraryScanResult, error) { ext := resolveLibraryAudioExt(filePath, displayNameHint) @@ -32,13 +28,14 @@ func scanAudioFileWithKnownModTimeAndDisplayNameAndCoverCacheKey(filePath, displ libraryCoverCacheMu.RUnlock() var scanned *LibraryScanResult var scanErr error - if ext == ".flac" { + switch ext { + case ".flac": scanned, scanErr = scanFLACFileWithCoverCache(filePath, result, displayNameHint, coverCacheDir, coverCacheKey) - } else if ext == ".m4a" || ext == ".mp4" || ext == ".aac" { + case ".m4a", ".mp4", ".aac": scanned, scanErr = scanM4AFileWithCoverCache(filePath, result, displayNameHint, coverCacheDir, coverCacheKey) - } else if ext == ".mp3" { + case ".mp3": scanned, scanErr = scanMP3FileWithCoverCache(filePath, result, displayNameHint, coverCacheDir, coverCacheKey) - } else { + default: if coverCacheDir != "" { coverPath, err := SaveCoverToCacheWithHintAndKey( filePath, @@ -184,10 +181,6 @@ func scanFLACFileWithCoverCache(filePath string, result *LibraryScanResult, disp return result, nil } -func scanM4AFile(filePath string, result *LibraryScanResult, displayNameHint string) (*LibraryScanResult, error) { - return scanM4AFileWithCoverCache(filePath, result, displayNameHint, "", "") -} - func scanM4AFileWithCoverCache(filePath string, result *LibraryScanResult, displayNameHint, coverCacheDir, coverCacheKey string) (*LibraryScanResult, error) { f, err := os.Open(filePath) if err != nil { @@ -276,10 +269,6 @@ func isLosslessLibraryFormat(format string) bool { } } -func scanMP3File(filePath string, result *LibraryScanResult, displayNameHint string) (*LibraryScanResult, error) { - return scanMP3FileWithCoverCache(filePath, result, displayNameHint, "", "") -} - func scanMP3FileWithCoverCache(filePath string, result *LibraryScanResult, displayNameHint, cacheDir, cacheKey string) (*LibraryScanResult, error) { wantCover := cacheDir != "" if wantCover { diff --git a/go_backend/lyrics.go b/go_backend/lyrics.go index 94ce1b63..80406489 100644 --- a/go_backend/lyrics.go +++ b/go_backend/lyrics.go @@ -623,10 +623,6 @@ func isKnownBuiltInLyricsProvider(providerName string) bool { } } -func (c *LyricsClient) fetchBuiltInLyricsProvider(providerName string, request lyricsProviderSearchRequest) (*LyricsResponse, error, bool) { - return c.fetchBuiltInLyricsProviderContext(context.Background(), providerName, request) -} - func (c *LyricsClient) fetchBuiltInLyricsProviderContext(ctx context.Context, providerName string, request lyricsProviderSearchRequest) (*LyricsResponse, error, bool) { clientCopy := *c clientCopy.httpClient = bindLyricsHTTPClientContext(c.httpClient, ctx) diff --git a/test/local_track_batch_actions_test.dart b/test/local_track_batch_actions_test.dart index d0ade150..83c2a945 100644 --- a/test/local_track_batch_actions_test.dart +++ b/test/local_track_batch_actions_test.dart @@ -37,12 +37,12 @@ class _BatchSettings extends SettingsNotifier { class _BatchLibrary extends LocalLibraryNotifier { final refreshed = Completer(); - bool refreshStarted = false; + bool _refreshStarted = false; @override LocalLibraryState build() => LocalLibraryState(); @override Future scanAllSources({bool forceFullScan = false}) { - refreshStarted = true; + _refreshStarted = true; return refreshed.future; } } @@ -301,7 +301,7 @@ void main() { expect(settings.phases.length, 1); await tester.tap(find.text('Apply changes')); await tester.pumpAndSettle(); - expect(library.refreshStarted, isTrue); + expect(library._refreshStarted, isTrue); expect(settings.phases.length, 2); active = !leaveDuringRefresh; library.refreshed.complete();