Fix auto-recovery re-download for encrypted RAR5 archives
- Always force re-download once when both JVM and legacy extractors fail (suggestRedownload=true), regardless of valid archive signature - Add autoRecoveredForRedownload Set for loop protection (one attempt per archive) - Clear loop protection on package reset (clearHybridArchiveState) - Previous sibling-items check failed when other episodes were already cleaned up after hybrid extraction - Lower mini-download retry threshold from 100KB to 5KB Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cd5c0c5e7b
commit
6b22c93554
@ -95,7 +95,7 @@ const DEFAULT_LOW_THROUGHPUT_TIMEOUT_MS = 120000;
|
|||||||
|
|
||||||
const DEFAULT_LOW_THROUGHPUT_MIN_BYTES = 64 * 1024;
|
const DEFAULT_LOW_THROUGHPUT_MIN_BYTES = 64 * 1024;
|
||||||
|
|
||||||
const MINI_DOWNLOAD_RETRY_THRESHOLD_BYTES = 100 * 1024;
|
const MINI_DOWNLOAD_RETRY_THRESHOLD_BYTES = 5 * 1024;
|
||||||
|
|
||||||
const ALLDEBRID_HOST_INFO_TTL_MS = 60000;
|
const ALLDEBRID_HOST_INFO_TTL_MS = 60000;
|
||||||
|
|
||||||
@ -1106,6 +1106,9 @@ export class DownloadManager extends EventEmitter {
|
|||||||
// archives are not retried on every subsequent post-processing wake-up.
|
// archives are not retried on every subsequent post-processing wake-up.
|
||||||
private hybridFailedArchives = new Map<string, Map<string, HybridFailedArchiveState>>();
|
private hybridFailedArchives = new Map<string, Map<string, HybridFailedArchiveState>>();
|
||||||
|
|
||||||
|
/** Archives already auto-recovered via forced re-download (loop protection). */
|
||||||
|
private autoRecoveredForRedownload = new Set<string>();
|
||||||
|
|
||||||
private reservedTargetPaths = new Map<string, string>();
|
private reservedTargetPaths = new Map<string, string>();
|
||||||
|
|
||||||
private claimedTargetPathByItem = new Map<string, string>();
|
private claimedTargetPathByItem = new Map<string, string>();
|
||||||
@ -4169,6 +4172,10 @@ export class DownloadManager extends EventEmitter {
|
|||||||
if (!archiveKey) {
|
if (!archiveKey) {
|
||||||
this.hybridExtractedPaths.delete(packageId);
|
this.hybridExtractedPaths.delete(packageId);
|
||||||
this.hybridFailedArchives.delete(packageId);
|
this.hybridFailedArchives.delete(packageId);
|
||||||
|
// Also clear re-download loop protection for this package
|
||||||
|
for (const key of this.autoRecoveredForRedownload) {
|
||||||
|
if (key.startsWith(`${packageId}::`)) this.autoRecoveredForRedownload.delete(key);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4273,24 +4280,25 @@ export class DownloadManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasValidSignature) {
|
if (hasValidSignature) {
|
||||||
// Check if other archives in this package were successfully extracted.
|
// Valid signature + suggestRedownload means both JVM and legacy extractors failed
|
||||||
// If a known password worked for siblings but NOT for this archive,
|
// (CRC/password error). Even with a valid header the content can be corrupt –
|
||||||
// the file is very likely corrupt despite having a valid header.
|
// encrypted RAR5 produces "Checksum error" indistinguishable from wrong password.
|
||||||
const otherItemsExtracted = items.some((item) =>
|
// Force re-download ONCE; use autoRecoveredForRedownload Set for loop protection.
|
||||||
item.status === "completed" && isExtractedLabel(item.fullStatus)
|
const redownloadKey = `${pkg.id}::${failure.archiveName}`;
|
||||||
&& !archiveItems.includes(item)
|
if (this.autoRecoveredForRedownload.has(redownloadKey)) {
|
||||||
);
|
|
||||||
if (otherItemsExtracted) {
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Auto-Recovery (${scope}): ${failure.archiveName} - Signatur gueltig aber ` +
|
`Auto-Recovery (${scope}): ${failure.archiveName} uebersprungen - ` +
|
||||||
`andere Archive im Paket bereits entpackt (bekanntes Passwort existiert). ` +
|
`wurde bereits einmal per Re-Download versucht (Loop-Schutz)`
|
||||||
`Erzwinge Re-Download aller ${archiveItems.length} Parts (wahrscheinliche Korruption)`
|
|
||||||
);
|
);
|
||||||
corruptArchiveItems.push(...inspectedArchiveItems);
|
|
||||||
} else {
|
|
||||||
logger.warn(`Auto-Recovery (${scope}): ${failure.archiveName} uebersprungen - Dateien korrekte Groesse, Archiv-Signatur gueltig (vermutlich falsches Passwort)`);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
this.autoRecoveredForRedownload.add(redownloadKey);
|
||||||
|
logger.warn(
|
||||||
|
`Auto-Recovery (${scope}): ${failure.archiveName} - Signatur gueltig, ` +
|
||||||
|
`beide Extraktoren fehlgeschlagen (suggestRedownload). ` +
|
||||||
|
`Erzwinge Re-Download aller ${archiveItems.length} Parts`
|
||||||
|
);
|
||||||
|
corruptArchiveItems.push(...inspectedArchiveItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user