Detect hoster error-page downloads (<512 B) and trigger retry
Some checks are pending
Build and Release / build (push) Waiting to run
Some checks are pending
Build and Release / build (push) Waiting to run
Some hosters return tiny error responses (e.g. 9 bytes) with HTTP 200. - downloadToFile: detect files <512 B, log content, delete and throw for retry - Post-download: catch <512 B files even when totalBytes is unknown - Logs the error-page content for debugging Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
122c797652
commit
c28384e78d
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "real-debrid-downloader",
|
||||
"version": "1.4.81",
|
||||
"version": "1.4.82",
|
||||
"description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)",
|
||||
"main": "build/main/main/main.js",
|
||||
"author": "Sucukdeluxe",
|
||||
|
||||
@ -3437,6 +3437,7 @@ export class DownloadManager extends EventEmitter {
|
||||
// A real archive part or video file should be at least 1 KB.
|
||||
const tooSmall = expectsNonEmptyFile && (
|
||||
fileSizeOnDisk <= 0
|
||||
|| fileSizeOnDisk < 512
|
||||
|| (item.totalBytes && item.totalBytes > 10240 && fileSizeOnDisk < 1024)
|
||||
);
|
||||
if (tooSmall) {
|
||||
@ -4106,6 +4107,24 @@ export class DownloadManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
// Detect tiny error-response files (e.g. hoster returning "Forbidden" with HTTP 200).
|
||||
// No legitimate file-hoster download is < 512 bytes.
|
||||
if (written > 0 && written < 512) {
|
||||
let snippet = "";
|
||||
try {
|
||||
snippet = await fs.promises.readFile(effectiveTargetPath, "utf8");
|
||||
snippet = snippet.slice(0, 200).replace(/[\r\n]+/g, " ").trim();
|
||||
} catch { /* ignore */ }
|
||||
logger.warn(`Tiny download erkannt (${written} B): "${snippet}"`);
|
||||
try {
|
||||
await fs.promises.rm(effectiveTargetPath, { force: true });
|
||||
} catch { /* ignore */ }
|
||||
this.dropItemContribution(active.itemId);
|
||||
item.downloadedBytes = 0;
|
||||
item.progressPercent = 0;
|
||||
throw new Error(`Download zu klein (${written} B) – Hoster-Fehlerseite?${snippet ? ` Inhalt: "${snippet}"` : ""}`);
|
||||
}
|
||||
|
||||
item.downloadedBytes = written;
|
||||
item.progressPercent = item.totalBytes ? Math.max(0, Math.min(100, Math.floor((written / item.totalBytes) * 100))) : 100;
|
||||
item.speedBps = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user