Files
Multi-Debrid-Downloader/tests/helpers/package-output-scope.ts
T
Sucukdeluxe 0d73f7e074 fix(downloads): restore hardened output scope release gates
Detect stale or foreign files in package-specific extraction directories before starting fresh work while excluding current and atomic ownership markers.

Keep recursive directory inspection confined to the start-conflict boundary and let archive cleanup prune empty package directories directly.

Register German-audio, auto-rename, collection, hybrid, and legacy fixtures through real complete PackageOutputScope records with current method signatures.

Verify plain stops only persist after active work drains, while update-restart parking keeps both its immediate checkpoint and final queued state.
2026-08-22 18:24:50 +02:00

25 lines
1.0 KiB
TypeScript

import path from "node:path";
import { PackageOutputScope } from "../../src/main/package-output-scope";
import type { PackageEntry } from "../../src/shared/types";
export function registerPackageCompleteOutputs(pkg: PackageEntry, outputPaths: readonly string[]): PackageOutputScope {
const roots = [pkg.outputDir, pkg.extractDir].filter((root): root is string => Boolean(String(root || "").trim()));
const scope = new PackageOutputScope(roots);
const archivePath = path.resolve(pkg.outputDir || pkg.extractDir, "fixture-source.archive");
for (const outputPath of outputPaths) {
const relativePath = path.relative(pkg.extractDir, outputPath).replace(/\\/g, "/");
scope.add({
version: 1,
archivePath,
entryPath: relativePath && !relativePath.startsWith("../") ? relativePath : path.basename(outputPath),
outputPath,
state: "complete",
disposition: "written"
});
}
pkg.outputProvenanceVersion = 1;
pkg.outputRecords = scope.records();
pkg.outputCount = scope.records().length;
return scope;
}