fix: resolve backend and test analyzer diagnostics

This commit is contained in:
zarzet
2026-09-06 16:14:57 +07:00
parent 1b0c28b91a
commit 70a2a92558
11 changed files with 15 additions and 67 deletions
-5
View File
@@ -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)
}
@@ -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 {
-7
View File
@@ -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.
+3 -2
View File
@@ -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)
-17
View File
@@ -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
+2 -1
View File
@@ -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")
}
-10
View File
@@ -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,
+1 -1
View File
@@ -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 {
+5 -16
View File
@@ -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 {
-4
View File
@@ -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)
+3 -3
View File
@@ -37,12 +37,12 @@ class _BatchSettings extends SettingsNotifier {
class _BatchLibrary extends LocalLibraryNotifier {
final refreshed = Completer<void>();
bool refreshStarted = false;
bool _refreshStarted = false;
@override
LocalLibraryState build() => LocalLibraryState();
@override
Future<void> 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();