mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-04 01:00:44 +02:00
chore(logging): sanitize diagnostics and reduce noise
This commit is contained in:
@@ -1132,12 +1132,8 @@ final downloadHistoryExistsProvider = FutureProvider.autoDispose
|
||||
);
|
||||
});
|
||||
|
||||
// Deliberately no per-row verifyOrRepairHistoryItem here (issue #495): on a
|
||||
// >500-track playlist that verify pass meant one SAF stat round-trip per
|
||||
// already-downloaded track, and any loadedIndexVersion bump mid-pass restarted
|
||||
// it from zero — above ~500 tracks the future never settled and "Download all"
|
||||
// silently did nothing. Stale rows are reconciled by the startup repair and
|
||||
// orphan-cleanup passes; the single-track provider above keeps the verify.
|
||||
// Batch lookups deliberately avoid per-row SAF verification. Startup repair
|
||||
// reconciles stale rows; the single-track provider above keeps strict checks.
|
||||
final downloadHistoryBatchExistsProvider = FutureProvider.autoDispose
|
||||
.family<Set<String>, HistoryBatchLookupRequest>((ref, request) async {
|
||||
ref.watch(
|
||||
|
||||
@@ -328,7 +328,7 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
'download_queue_native_worker_run_id';
|
||||
static const _userPausedQueuePrefsKey = 'download_queue_user_paused_v1';
|
||||
static const _bytesUiStep = 104857; // ~0.1 MiB, matches one-decimal MB UI.
|
||||
static const _progressLogStepPercent = 5;
|
||||
static const _progressLogStepPercent = 10;
|
||||
static const _serviceProgressStepPercent = 2;
|
||||
static const _decryptStageSafAccess = 'safAccess';
|
||||
static const _decryptStageDecrypt = 'decrypt';
|
||||
@@ -735,10 +735,6 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
..clear()
|
||||
..addAll(currentItemsById);
|
||||
_nonCanonicalPersistedQueueIds.clear();
|
||||
_log.d(
|
||||
'Persisted ${upserts.length} changed and removed '
|
||||
'${deletedIds.length} queue items',
|
||||
);
|
||||
} catch (e) {
|
||||
_log.e('Failed to save queue to storage: $e');
|
||||
}
|
||||
@@ -1525,7 +1521,6 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
await failedDir.create(recursive: true);
|
||||
}
|
||||
|
||||
// Use date-only format for daily grouping (YYYY-MM-DD)
|
||||
final now = DateTime.now();
|
||||
final dateStr =
|
||||
'${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')}';
|
||||
@@ -1816,11 +1811,7 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
state = state.copyWith(outputDir: musicDir.path);
|
||||
}
|
||||
|
||||
if (!isSafMode) {
|
||||
_log.d('Output directory: ${state.outputDir}');
|
||||
} else {
|
||||
_log.d('Output directory: SAF (tree_uri=${settings.downloadTreeUri})');
|
||||
}
|
||||
_log.d('Download storage mode: ${isSafMode ? 'SAF' : 'filesystem'}');
|
||||
|
||||
if (!isSafMode &&
|
||||
Platform.isIOS &&
|
||||
@@ -1957,7 +1948,6 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
_log.d('Queue is paused and no active download remains');
|
||||
break;
|
||||
}
|
||||
_log.d('Queue is paused, waiting for active download...');
|
||||
await Future.any([
|
||||
Future.wait(activeDownloads.values),
|
||||
Future<void>.delayed(_queueSchedulingInterval),
|
||||
|
||||
@@ -1057,7 +1057,6 @@ extension _DownloadQueueEmbedding on DownloadQueueNotifier {
|
||||
_log.w('Failed to download cover: ${result['error']}');
|
||||
return null;
|
||||
}
|
||||
_log.d('Cover downloaded for embedding: $coverPath');
|
||||
return coverPath;
|
||||
} catch (e) {
|
||||
_log.e('Failed to download cover for embedding: $e');
|
||||
|
||||
@@ -76,11 +76,8 @@ extension _SingleItemDownload on DownloadQueueNotifier {
|
||||
|
||||
/// One download attempt for a single queue item.
|
||||
///
|
||||
/// What used to be the ~35 locals of a 1,700-line method live here as fields
|
||||
/// so the pipeline reads as stage methods: enrich -> resolve output ->
|
||||
/// resolve identifiers -> download (with SAF fallback) -> decrypt / convert /
|
||||
/// embed -> publish to history. `n` is the owning notifier; queue state and
|
||||
/// shared helpers stay there.
|
||||
/// The stage order is enrich -> resolve output -> resolve identifiers ->
|
||||
/// download -> decrypt/convert/embed -> publish. `n` owns shared queue state.
|
||||
class _DownloadRun {
|
||||
_DownloadRun(this.n, this.item);
|
||||
|
||||
@@ -157,7 +154,6 @@ class _DownloadRun {
|
||||
}
|
||||
|
||||
_log.d('Processing: ${item.track.name} by ${item.track.artistName}');
|
||||
_log.d('Cover URL: ${item.track.coverUrl}');
|
||||
|
||||
final currentItem = n._findItemById(item.id) ?? item;
|
||||
if (n._isLocallyCancelled(item.id, item: currentItem)) {
|
||||
@@ -210,7 +206,12 @@ class _DownloadRun {
|
||||
|
||||
if (!await _downloadAndMaybeFallback()) return;
|
||||
|
||||
_log.d('Result: $result');
|
||||
_log.d(
|
||||
'Native download result: success=${result['success'] == true}, '
|
||||
'service=${result['service'] ?? item.service}, '
|
||||
'errorType=${result['error_type'] ?? 'none'}, '
|
||||
'filePresent=${(result['file_path'] as String?)?.isNotEmpty == true}',
|
||||
);
|
||||
|
||||
final extendedMetadata = await extendedMetadataFuture;
|
||||
if (extendedMetadata != null) {
|
||||
@@ -663,11 +664,7 @@ class _DownloadRun {
|
||||
}
|
||||
|
||||
wasExisting = result['already_exists'] == true;
|
||||
if (wasExisting) {
|
||||
_log.i('File already exists in library: $filePath');
|
||||
}
|
||||
|
||||
_log.i('Download success, file: $filePath');
|
||||
_log.i('Download completed (existing=$wasExisting)');
|
||||
|
||||
final actualBitDepth = result['actual_bit_depth'] as int?;
|
||||
final actualSampleRate = result['actual_sample_rate'] as int?;
|
||||
@@ -716,8 +713,6 @@ class _DownloadRun {
|
||||
result,
|
||||
resolvedAlbumArtist,
|
||||
);
|
||||
_log.d('Track coverUrl after download result: ${trackToDownload.coverUrl}');
|
||||
|
||||
if (!await _decryptIfNeeded()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1805,8 +1800,6 @@ class _DownloadRun {
|
||||
}
|
||||
}
|
||||
|
||||
_log.d('Saving to history - coverUrl: ${trackToDownload.coverUrl}');
|
||||
|
||||
final isLossyOutput =
|
||||
isLossyAudioFormat(finalFormat) ||
|
||||
lowerFilePath.endsWith('.mp3') ||
|
||||
|
||||
@@ -357,18 +357,14 @@ class ExploreNotifier extends Notifier<ExploreState> {
|
||||
});
|
||||
await prefs.setString(_cacheKey, encoded);
|
||||
await prefs.setInt(_cacheTsKey, DateTime.now().millisecondsSinceEpoch);
|
||||
_log.d('Saved ${normalizedSections.length} explore sections to cache');
|
||||
} catch (e) {
|
||||
_log.w('Failed to save explore cache: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchHomeFeed({bool forceRefresh = false}) async {
|
||||
_log.i('fetchHomeFeed called, forceRefresh=$forceRefresh');
|
||||
|
||||
if (ref.read(settingsProvider).homeFeedProvider ==
|
||||
AppSettings.homeFeedProviderOff) {
|
||||
_log.d('Home feed disabled by user setting');
|
||||
_homeFeedRequestId++;
|
||||
PlatformBridge.cancelExtensionHomeFeedRequests();
|
||||
state = const ExploreState();
|
||||
@@ -393,13 +389,6 @@ class ExploreNotifier extends Notifier<ExploreState> {
|
||||
state = state.copyWith(isLoading: showLoading, error: null);
|
||||
|
||||
try {
|
||||
final extState = ref.read(extensionProvider);
|
||||
final settings = ref.read(settingsProvider);
|
||||
final preferredId = settings.homeFeedProvider;
|
||||
_log.d(
|
||||
'Extensions count: ${extState.extensions.length}, preferred home feed: $preferredId',
|
||||
);
|
||||
|
||||
final targetExt = _resolveHomeFeedExtension();
|
||||
|
||||
if (targetExt == null) {
|
||||
@@ -412,7 +401,6 @@ class ExploreNotifier extends Notifier<ExploreState> {
|
||||
return;
|
||||
}
|
||||
|
||||
_log.i('Fetching home feed from ${targetExt.id}...');
|
||||
final result = await PlatformBridge.getExtensionHomeFeed(
|
||||
targetExt.id,
|
||||
cancelPrevious: forceRefresh,
|
||||
@@ -428,14 +416,12 @@ class ExploreNotifier extends Notifier<ExploreState> {
|
||||
}
|
||||
|
||||
final success = result['success'] as bool? ?? false;
|
||||
_log.d('getExtensionHomeFeed success=$success');
|
||||
if (!success) {
|
||||
final error = result['error'] as String? ?? 'Unknown error';
|
||||
state = state.copyWith(isLoading: false, error: error);
|
||||
return;
|
||||
}
|
||||
|
||||
final greeting = result['greeting'] as String?;
|
||||
final sectionsData = result['sections'] as List<dynamic>? ?? [];
|
||||
final normalizedSectionsWithoutProvider = await compute(
|
||||
_normalizeExploreSectionsPayload,
|
||||
@@ -450,17 +436,11 @@ class ExploreNotifier extends Notifier<ExploreState> {
|
||||
normalizedSections,
|
||||
);
|
||||
|
||||
_log.i('Fetched ${sections.length} sections');
|
||||
|
||||
if (sections.isNotEmpty && sections.first.items.isNotEmpty) {
|
||||
final firstItem = sections.first.items.first;
|
||||
_log.d(
|
||||
'First item: name=${firstItem.name}, artists=${firstItem.artists}, type=${firstItem.type}',
|
||||
);
|
||||
}
|
||||
|
||||
final localGreeting = _getLocalGreeting();
|
||||
_log.d('Greeting from extension: $greeting, using local: $localGreeting');
|
||||
_log.i(
|
||||
'Home feed updated: provider=${targetExt.id}, '
|
||||
'sections=${sections.length}',
|
||||
);
|
||||
|
||||
state = ExploreState(
|
||||
isLoading: false,
|
||||
|
||||
@@ -110,7 +110,6 @@ class PreviewPlayerController extends Notifier<PreviewPlayerState> {
|
||||
);
|
||||
_subscriptions.add(
|
||||
player.onPlayerComplete.listen((_) {
|
||||
_log.d('Preview playback completed');
|
||||
state = const PreviewPlayerState();
|
||||
}),
|
||||
);
|
||||
@@ -178,7 +177,6 @@ class PreviewPlayerController extends Notifier<PreviewPlayerState> {
|
||||
);
|
||||
|
||||
try {
|
||||
_log.i('Starting preview playback');
|
||||
await _playOnPlayer(_ensurePlayer(), trimmed);
|
||||
} catch (e) {
|
||||
_log.w('Preview playback failed, recreating player and retrying: $e');
|
||||
|
||||
@@ -11,8 +11,7 @@ final lowEndDeviceProvider = Provider<bool>((ref) => false);
|
||||
final deviceSupportsBackdropBlurProvider = Provider<bool>((ref) => false);
|
||||
|
||||
/// Whether backdrop blur effects should render: the device default, or the
|
||||
/// user's manual override from appearance settings (issue #488 — let lower
|
||||
/// tiers opt back in).
|
||||
/// user's manual override from appearance settings.
|
||||
final backdropBlurEnabledProvider = Provider<bool>((ref) {
|
||||
return ref.watch(deviceSupportsBackdropBlurProvider) ||
|
||||
ref.watch(settingsProvider.select((s) => s.forceBackdropBlur));
|
||||
|
||||
@@ -175,7 +175,7 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
return;
|
||||
}
|
||||
|
||||
_log.i('Found extension URL handler: $extensionHandler for URL: $url');
|
||||
_log.i('Found extension URL handler: $extensionHandler');
|
||||
|
||||
Map<String, dynamic>? result;
|
||||
for (int attempt = 1; attempt <= 3; attempt++) {
|
||||
@@ -368,21 +368,12 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
try {
|
||||
final includeExtensions = settings.useExtensionProviders;
|
||||
|
||||
_log.i(
|
||||
'Search started: provider=metadata_extensions, query="$query", includeExtensions=$includeExtensions, filter=$requestFilter',
|
||||
);
|
||||
|
||||
_log.d('Calling metadata provider track search API...');
|
||||
final metadataTrackResults =
|
||||
await PlatformBridge.searchTracksWithMetadataProviders(
|
||||
query,
|
||||
limit: 20,
|
||||
includeExtensions: includeExtensions,
|
||||
);
|
||||
_log.i(
|
||||
'metadata_extensions returned ${metadataTrackResults.length} tracks',
|
||||
);
|
||||
|
||||
if (!_isRequestValid(requestId)) {
|
||||
_log.w('Search request cancelled (requestId=$requestId)');
|
||||
return;
|
||||
@@ -398,7 +389,11 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
}
|
||||
}
|
||||
|
||||
_log.i('Search complete: ${tracks.length} tracks parsed successfully');
|
||||
_log.i(
|
||||
'Search completed: provider=metadata_extensions, '
|
||||
'tracks=${tracks.length}, extensions=$includeExtensions, '
|
||||
'filter=$requestFilter',
|
||||
);
|
||||
|
||||
state = TrackState(
|
||||
tracks: tracks,
|
||||
@@ -439,8 +434,6 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
);
|
||||
|
||||
try {
|
||||
_log.i('Custom search started: extension=$extensionId, query="$query"');
|
||||
|
||||
final results = await PlatformBridge.customSearchWithExtension(
|
||||
extensionId,
|
||||
query,
|
||||
@@ -453,8 +446,6 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
return;
|
||||
}
|
||||
|
||||
_log.i('Custom search returned ${results.length} tracks');
|
||||
|
||||
final tracks = <Track>[];
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
final t = results[i];
|
||||
@@ -466,13 +457,8 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
}
|
||||
|
||||
_log.i(
|
||||
'Custom search complete: ${tracks.length} tracks parsed (source=$extensionId)',
|
||||
);
|
||||
|
||||
final previewCount = tracks.where((t) => t.hasPreview).length;
|
||||
_log.d(
|
||||
'Custom search preview availability: $previewCount/${tracks.length} tracks have preview_url'
|
||||
'${results.isNotEmpty ? '; first raw keys=${(results.first).keys.toList()}' : ''}',
|
||||
'Custom search completed: extension=$extensionId, '
|
||||
'tracks=${tracks.length}',
|
||||
);
|
||||
|
||||
state = TrackState(
|
||||
|
||||
Reference in New Issue
Block a user