v2.42.2 — HIGH: Background-Service try/finally + MEDIUM: debugPrint Leak

## HIGH: Background-Service bleibt hängen
- downloadVonUrl: try/finally stellt sicher dass _stopBackgroundService() immer aufgerufen wird
- downloadBatch: try/finally stellt sicher dass _stopBackgroundService() immer aufgerufen wird
- reDownload: try/finally stellt sicher dass _stopBackgroundService() immer aufgerufen wird

## MEDIUM: debugPrint Leak
- HTTP-Response-Body in debugPrint auf max 200 Zeichen gekürzt
This commit is contained in:
Dustin
2026-08-02 17:00:27 +02:00
parent b5b1475d5d
commit 50a810934d
+14 -5
View File
@@ -104,14 +104,17 @@ class DownloadService extends ChangeNotifier {
/// Song von YouTube herunterladen
Future<Song?> downloadVonUrl(String url) async {
_resetStatus();
final result = await _downloadEinzeln(url);
if (!_ladt) _stopBackgroundService();
return result;
try {
return await _downloadEinzeln(url);
} finally {
_stopBackgroundService();
}
}
/// Mehrere URLs/Playlists nacheinander mit Cooldown
Future<int> downloadBatch(String input, {int cooldownSekunden = 5}) async {
_resetStatus();
try {
MeloLogger().zustand('download_batch_start', {
'input_len': input.length,
});
@@ -181,13 +184,15 @@ class DownloadService extends ChangeNotifier {
}
notifyListeners();
_completeNotification(erfolgreich, urls.length, abgebrochen: sollAbbrechen);
_stopBackgroundService();
MeloLogger().zustand('download_batch_ende', {
'erfolgreich': erfolgreich,
'gesamt': urls.length,
'abgebrochen': sollAbbrechen,
});
return erfolgreich;
} finally {
_stopBackgroundService();
}
}
/// Einzelnen Song über den yt-proxy herunterladen
@@ -256,7 +261,7 @@ class DownloadService extends ChangeNotifier {
_fehler = 'Proxy-Fehler (${dlAntwort.statusCode}): $fehlerText';
_ladt = false;
notifyListeners();
debugPrint('Proxy-Fehler: ${dlAntwort.body}');
debugPrint('Proxy-Fehler: ${dlAntwort.body.length > 200 ? '${dlAntwort.body.substring(0, 200)}...' : dlAntwort.body}');
MeloLogger().netzwerk('POST', '$_proxyBasisUrl/api/yt-dl',
statusCode: dlAntwort.statusCode, fehler: fehlerText);
return null;
@@ -483,6 +488,7 @@ class DownloadService extends ChangeNotifier {
}
_resetStatus();
try {
_aktuellerTitel = '🔄 Lade neu: ${song.titel}';
notifyListeners();
@@ -501,6 +507,9 @@ class DownloadService extends ChangeNotifier {
// Neu herunterladen mit der gespeicherten ytUrl
return _downloadEinzeln(song.ytUrl!);
} finally {
_stopBackgroundService();
}
}
// ─── #9: Notification-Progress ─────────────────