Fix deferred post-extraction cleanup skipped after hybrid extraction
When hybrid extraction handled all archives, extractedCount stayed 0 causing all cleanup steps (archive deletion, resume state, link/sample removal, empty dir pruning, auto-rename, nested extraction) to be bypassed. Extended conditions to also trigger on alreadyMarkedExtracted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
44f202d116
commit
c380abaee2
@ -7039,7 +7039,7 @@ export class DownloadManager extends EventEmitter {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// ── Nested extraction: extract archives found inside the extracted output ──
|
// ── Nested extraction: extract archives found inside the extracted output ──
|
||||||
if (extractedCount > 0 && failed === 0 && this.settings.autoExtract) {
|
if ((extractedCount > 0 || alreadyMarkedExtracted) && failed === 0 && this.settings.autoExtract) {
|
||||||
const nestedBlacklist = /\.(iso|img|bin|dmg|vhd|vhdx|vmdk|wim)$/i;
|
const nestedBlacklist = /\.(iso|img|bin|dmg|vhd|vhdx|vmdk|wim)$/i;
|
||||||
const nestedCandidates = (await findArchiveCandidates(pkg.extractDir))
|
const nestedCandidates = (await findArchiveCandidates(pkg.extractDir))
|
||||||
.filter((p) => !nestedBlacklist.test(p));
|
.filter((p) => !nestedBlacklist.test(p));
|
||||||
@ -7066,14 +7066,16 @@ export class DownloadManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Auto-Rename ──
|
// ── Auto-Rename ──
|
||||||
if (extractedCount > 0) {
|
if (extractedCount > 0 || alreadyMarkedExtracted) {
|
||||||
pkg.postProcessLabel = "Renaming...";
|
pkg.postProcessLabel = "Renaming...";
|
||||||
this.emitState();
|
this.emitState();
|
||||||
await this.autoRenameExtractedVideoFiles(pkg.extractDir, pkg);
|
await this.autoRenameExtractedVideoFiles(pkg.extractDir, pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Archive cleanup (source archives in outputDir) ──
|
// ── Archive cleanup (source archives in outputDir) ──
|
||||||
if (extractedCount > 0 && failed === 0 && this.settings.cleanupMode !== "none") {
|
// Also run when hybrid extraction already handled everything (extractedCount=0
|
||||||
|
// but alreadyMarkedExtracted=true) so archives are still cleaned up.
|
||||||
|
if ((extractedCount > 0 || alreadyMarkedExtracted) && failed === 0 && this.settings.cleanupMode !== "none") {
|
||||||
pkg.postProcessLabel = "Aufräumen...";
|
pkg.postProcessLabel = "Aufräumen...";
|
||||||
this.emitState();
|
this.emitState();
|
||||||
const sourceAndTargetEqual = path.resolve(pkg.outputDir).toLowerCase() === path.resolve(pkg.extractDir).toLowerCase();
|
const sourceAndTargetEqual = path.resolve(pkg.outputDir).toLowerCase() === path.resolve(pkg.extractDir).toLowerCase();
|
||||||
@ -7097,7 +7099,7 @@ export class DownloadManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Link/Sample artifact removal ──
|
// ── Link/Sample artifact removal ──
|
||||||
if (extractedCount > 0 && failed === 0) {
|
if ((extractedCount > 0 || alreadyMarkedExtracted) && failed === 0) {
|
||||||
if (this.settings.removeLinkFilesAfterExtract) {
|
if (this.settings.removeLinkFilesAfterExtract) {
|
||||||
const removedLinks = await removeDownloadLinkArtifacts(pkg.extractDir);
|
const removedLinks = await removeDownloadLinkArtifacts(pkg.extractDir);
|
||||||
if (removedLinks > 0) {
|
if (removedLinks > 0) {
|
||||||
@ -7113,14 +7115,14 @@ export class DownloadManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Resume state cleanup ──
|
// ── Resume state cleanup ──
|
||||||
if (extractedCount > 0 && failed === 0) {
|
if ((extractedCount > 0 || alreadyMarkedExtracted) && failed === 0) {
|
||||||
await clearExtractResumeState(pkg.outputDir, packageId);
|
await clearExtractResumeState(pkg.outputDir, packageId);
|
||||||
// Backward compatibility: older versions used .rd_extract_progress.json without package suffix.
|
// Backward compatibility: older versions used .rd_extract_progress.json without package suffix.
|
||||||
await clearExtractResumeState(pkg.outputDir);
|
await clearExtractResumeState(pkg.outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Empty directory tree removal ──
|
// ── Empty directory tree removal ──
|
||||||
if (extractedCount > 0 && failed === 0 && this.settings.cleanupMode === "delete") {
|
if ((extractedCount > 0 || alreadyMarkedExtracted) && failed === 0 && this.settings.cleanupMode === "delete") {
|
||||||
if (!(await hasAnyFilesRecursive(pkg.outputDir))) {
|
if (!(await hasAnyFilesRecursive(pkg.outputDir))) {
|
||||||
const removedDirs = await removeEmptyDirectoryTree(pkg.outputDir);
|
const removedDirs = await removeEmptyDirectoryTree(pkg.outputDir);
|
||||||
if (removedDirs > 0) {
|
if (removedDirs > 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user