mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-12 09:58:10 +02:00
Auto-delete download if likely invalid (#1498)
This commit is contained in:
@@ -291,11 +291,14 @@ Future<File> downloadFile(
|
|||||||
return s;
|
return s;
|
||||||
}).pipe(sink);
|
}).pipe(sink);
|
||||||
await sink.close();
|
await sink.close();
|
||||||
|
bool likelyCorruptFile = (progress ?? 0) > 101;
|
||||||
progress = null;
|
progress = null;
|
||||||
if (onProgress != null) {
|
if (onProgress != null) {
|
||||||
onProgress(progress);
|
onProgress(progress);
|
||||||
}
|
}
|
||||||
if (response.statusCode < 200 || response.statusCode > 299) {
|
if (response.statusCode < 200 ||
|
||||||
|
response.statusCode > 299 ||
|
||||||
|
likelyCorruptFile) {
|
||||||
tempDownloadedFile.deleteSync(recursive: true);
|
tempDownloadedFile.deleteSync(recursive: true);
|
||||||
throw response.reasonPhrase ?? tr('unexpectedError');
|
throw response.reasonPhrase ?? tr('unexpectedError');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user