fix: optimize workDir copy cleanup and handle extension mismatch in replaceOriginalFile
Build / Lint & Test (push) Successful in 14s

This commit is contained in:
PickleRick committed 2026-09-30 18:35:35 +02:00
1 parent 07b730c81f
commit f2e483ca1f
2 files changed
+40 -6

No files matched your search

@@ -278,6 +278,13 @@ const plugin = async (args) => {
throw new Error(`[transcode2PassX265] Video-copy/audio-transcode failed with exit code ${cliExitCode}`);
}
if (variables.workDirCopyApplied === 'true' && fs.existsSync(inputFile)) {
try {
fs.unlinkSync(inputFile);
jobLog(`[transcode2PassX265] Cleaned up temporary workDir copy: ${path.basename(inputFile)}\n`);
} catch (_) { /* ignore */ }
}
jobLog(`[transcode2PassX265] Done. Output: ${outFile}\n`);
return {
outputNumber: 1,
@@ -351,11 +358,17 @@ const plugin = async (args) => {
}
jobLog('[transcode2PassX265] Pass 2 complete.\n');
// ── Cleanup 2-pass log files ──────────────────────────────────────────────
// ── Cleanup 2-pass log files and temporary input copy ────────────────────
[statsFile, `${statsFile}.mbtree`, `${statsFile}.cutree`].forEach((f) => {
try { if (fs.existsSync(f)) fs.unlinkSync(f); } catch (_) { /* ignore */ }
});
jobLog('[transcode2PassX265] Temp log files cleaned up.\n');
if (variables.workDirCopyApplied === 'true' && fs.existsSync(inputFile)) {
try {
fs.unlinkSync(inputFile);
jobLog(`[transcode2PassX265] Cleaned up temporary workDir copy: ${path.basename(inputFile)}\n`);
} catch (_) { /* ignore */ }
}
jobLog('[transcode2PassX265] Temp files cleaned up.\n');
// ── Return transcoded file for Tdarr to manage ────────────────────────────
jobLog(`[transcode2PassX265] Done. Output: ${outFile}\n`);