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:
@@ -104,14 +104,17 @@ class DownloadService extends ChangeNotifier {
|
|||||||
/// Song von YouTube herunterladen
|
/// Song von YouTube herunterladen
|
||||||
Future<Song?> downloadVonUrl(String url) async {
|
Future<Song?> downloadVonUrl(String url) async {
|
||||||
_resetStatus();
|
_resetStatus();
|
||||||
final result = await _downloadEinzeln(url);
|
try {
|
||||||
if (!_ladt) _stopBackgroundService();
|
return await _downloadEinzeln(url);
|
||||||
return result;
|
} finally {
|
||||||
|
_stopBackgroundService();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mehrere URLs/Playlists nacheinander mit Cooldown
|
/// Mehrere URLs/Playlists nacheinander mit Cooldown
|
||||||
Future<int> downloadBatch(String input, {int cooldownSekunden = 5}) async {
|
Future<int> downloadBatch(String input, {int cooldownSekunden = 5}) async {
|
||||||
_resetStatus();
|
_resetStatus();
|
||||||
|
try {
|
||||||
MeloLogger().zustand('download_batch_start', {
|
MeloLogger().zustand('download_batch_start', {
|
||||||
'input_len': input.length,
|
'input_len': input.length,
|
||||||
});
|
});
|
||||||
@@ -181,13 +184,15 @@ class DownloadService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_completeNotification(erfolgreich, urls.length, abgebrochen: sollAbbrechen);
|
_completeNotification(erfolgreich, urls.length, abgebrochen: sollAbbrechen);
|
||||||
_stopBackgroundService();
|
|
||||||
MeloLogger().zustand('download_batch_ende', {
|
MeloLogger().zustand('download_batch_ende', {
|
||||||
'erfolgreich': erfolgreich,
|
'erfolgreich': erfolgreich,
|
||||||
'gesamt': urls.length,
|
'gesamt': urls.length,
|
||||||
'abgebrochen': sollAbbrechen,
|
'abgebrochen': sollAbbrechen,
|
||||||
});
|
});
|
||||||
return erfolgreich;
|
return erfolgreich;
|
||||||
|
} finally {
|
||||||
|
_stopBackgroundService();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Einzelnen Song über den yt-proxy herunterladen
|
/// Einzelnen Song über den yt-proxy herunterladen
|
||||||
@@ -256,7 +261,7 @@ class DownloadService extends ChangeNotifier {
|
|||||||
_fehler = 'Proxy-Fehler (${dlAntwort.statusCode}): $fehlerText';
|
_fehler = 'Proxy-Fehler (${dlAntwort.statusCode}): $fehlerText';
|
||||||
_ladt = false;
|
_ladt = false;
|
||||||
notifyListeners();
|
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',
|
MeloLogger().netzwerk('POST', '$_proxyBasisUrl/api/yt-dl',
|
||||||
statusCode: dlAntwort.statusCode, fehler: fehlerText);
|
statusCode: dlAntwort.statusCode, fehler: fehlerText);
|
||||||
return null;
|
return null;
|
||||||
@@ -483,6 +488,7 @@ class DownloadService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_resetStatus();
|
_resetStatus();
|
||||||
|
try {
|
||||||
_aktuellerTitel = '🔄 Lade neu: ${song.titel}';
|
_aktuellerTitel = '🔄 Lade neu: ${song.titel}';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
@@ -501,6 +507,9 @@ class DownloadService extends ChangeNotifier {
|
|||||||
|
|
||||||
// Neu herunterladen mit der gespeicherten ytUrl
|
// Neu herunterladen mit der gespeicherten ytUrl
|
||||||
return _downloadEinzeln(song.ytUrl!);
|
return _downloadEinzeln(song.ytUrl!);
|
||||||
|
} finally {
|
||||||
|
_stopBackgroundService();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── #9: Notification-Progress ─────────────────
|
// ─── #9: Notification-Progress ─────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user