Add item-recovery for stuck downloads with completed files on disk
Some checks are pending
Build and Release / build (push) Waiting to run
Some checks are pending
Build and Release / build (push) Waiting to run
When post-processing runs, detect items in idle states (queued/paused) whose target file already exists on disk with non-zero size, and auto-recover them to "completed" status. This ensures allDone becomes true, triggering final extraction with archive cleanup (delete mode). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d8a53dcea6
commit
13ff41aa95
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "real-debrid-downloader",
|
||||
"version": "1.4.77",
|
||||
"version": "1.4.78",
|
||||
"description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)",
|
||||
"main": "build/main/main/main.js",
|
||||
"author": "Sucukdeluxe",
|
||||
|
||||
@ -4720,6 +4720,36 @@ export class DownloadManager extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
const items = pkg.itemIds.map((id) => this.session.items[id]).filter(Boolean) as DownloadItem[];
|
||||
|
||||
// Recover items whose file exists on disk but status was never set to "completed".
|
||||
// Only recover items in idle states (queued/paused), never active ones (downloading/validating).
|
||||
for (const item of items) {
|
||||
if (isFinishedStatus(item.status)) {
|
||||
continue;
|
||||
}
|
||||
if (item.status === "downloading" || item.status === "validating" || item.status === "integrity_check") {
|
||||
continue;
|
||||
}
|
||||
if (!item.targetPath) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const stat = fs.statSync(item.targetPath);
|
||||
if (stat.size > 0) {
|
||||
logger.info(`Item-Recovery: ${item.fileName} war "${item.status}" aber Datei existiert (${humanSize(stat.size)}), setze auf completed`);
|
||||
item.status = "completed";
|
||||
item.fullStatus = this.settings.autoExtract ? "Entpacken - Ausstehend" : `Fertig (${humanSize(stat.size)})`;
|
||||
item.downloadedBytes = stat.size;
|
||||
item.progressPercent = 100;
|
||||
item.speedBps = 0;
|
||||
item.updatedAt = nowMs();
|
||||
this.recordRunOutcome(item.id, "completed");
|
||||
}
|
||||
} catch {
|
||||
// file doesn't exist, nothing to recover
|
||||
}
|
||||
}
|
||||
|
||||
const success = items.filter((item) => item.status === "completed").length;
|
||||
const failed = items.filter((item) => item.status === "failed").length;
|
||||
const cancelled = items.filter((item) => item.status === "cancelled").length;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user