Eliminate 10-15s pause between package extractions

Release post-process slot immediately after main extraction completes.
All slow post-extraction work (nested extraction, auto-rename, archive
cleanup, link/sample removal, empty directory cleanup, MKV collection)
now runs in background via runDeferredPostExtraction so the next package
can start unpacking without delay.

- Export hasAnyFilesRecursive, removeEmptyDirectoryTree, cleanupArchives
  from extractor.ts for use in deferred handler
- Import removeDownloadLinkArtifacts, removeSampleArtifacts from cleanup
- Expand runDeferredPostExtraction with full post-cleanup pipeline:
  nested extraction, rename, archive cleanup, link/sample removal,
  empty dir tree removal, resume state clearing, MKV collection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-05 04:22:20 +01:00
co-authored by Claude Opus 4.6
parent 9ddc7d31bb
commit 95cf4fbed8
2 changed files with 143 additions and 30 deletions
+3 -3
View File
@@ -1718,7 +1718,7 @@ export function collectArchiveCleanupTargets(sourceArchivePath: string, director
return Array.from(targets);
}
async function cleanupArchives(sourceFiles: string[], cleanupMode: CleanupMode): Promise<number> {
export async function cleanupArchives(sourceFiles: string[], cleanupMode: CleanupMode): Promise<number> {
if (cleanupMode === "none") {
return 0;
}
@@ -1789,7 +1789,7 @@ async function cleanupArchives(sourceFiles: string[], cleanupMode: CleanupMode):
return removed;
}
async function hasAnyFilesRecursive(rootDir: string): Promise<boolean> {
export async function hasAnyFilesRecursive(rootDir: string): Promise<boolean> {
const rootExists = await fs.promises.access(rootDir).then(() => true, () => false);
if (!rootExists) {
return false;
@@ -1837,7 +1837,7 @@ async function hasAnyEntries(rootDir: string): Promise<boolean> {
}
}
async function removeEmptyDirectoryTree(rootDir: string): Promise<number> {
export async function removeEmptyDirectoryTree(rootDir: string): Promise<number> {
const rootExists = await fs.promises.access(rootDir).then(() => true, () => false);
if (!rootExists) {
return 0;