mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-28 04:46:07 -08:00
fix(subsync): address CodeRabbit review of cancellation, cleanup, and writes
- kill a tool's whole POSIX process group on cancel (orphaned children held the pipes open, so the run never finished); kill running groups on exit - refuse an in-place rewrite when the subtitle changed on disk mid-sync - pick only a freshly added track for the secondary slot, and reset its delay only after selecting it - pass cancellation to the video-reference alass and ffsubsync runs, and never open a picker for media the user already left - treat a failed media-path baseline read as unknown instead of null - align worker: honor aborts during startup and finish queued calls on the main thread when the worker fails to start - temp dirs: keep failed removals registered, never sweep a dir mpv still plays from, and clean up when writing a cleaned reference fails - an empty cached audio result means no usable audio, as on a fresh decode - compare external track paths case-sensitively on POSIX - decode ffmpeg stderr as a stream; coverage lane for subtitle tests - make the cancellation test wait for the tool to start
This commit is contained in:
12 files changed
+244
-57
No files matched your search
@@ -7,8 +7,6 @@ import { cleanupTemporaryFile, pruneRetainedSubsyncTempDirs } from './subsync-fi
|
||||
|
||||
test('synced embedded-track temp dirs keep only the loaded file and go away once mpv drops it', () => {
|
||||
const isolatedTmp = fs.mkdtempSync(path.join(os.tmpdir(), 'subsync-files-test-'));
|
||||
const previousTmpDir = process.env.TMPDIR;
|
||||
process.env.TMPDIR = isolatedTmp;
|
||||
try {
|
||||
// Left behind by a crashed session two days ago.
|
||||
const staleDir = fs.mkdtempSync(path.join(isolatedTmp, 'subminer-subsync-'));
|
||||
@@ -25,15 +23,20 @@ test('synced embedded-track temp dirs keep only the loaded file and go away once
|
||||
cleanupTemporaryFile({ path: extractedPath, temporary: true });
|
||||
assert.deepEqual(fs.readdirSync(runDir), ['track_2_retimed.ass']);
|
||||
|
||||
pruneRetainedSubsyncTempDirs([retimedPath]);
|
||||
// An old dir whose file mpv still plays survives the sweep.
|
||||
const playingDir = fs.mkdtempSync(path.join(isolatedTmp, 'subminer-subsync-'));
|
||||
const playingPath = path.join(playingDir, 'track_4_retimed.srt');
|
||||
fs.writeFileSync(playingPath, 'still loaded');
|
||||
fs.utimesSync(playingDir, twoDaysAgo, twoDaysAgo);
|
||||
|
||||
pruneRetainedSubsyncTempDirs([retimedPath, playingPath], { tmpRoot: isolatedTmp });
|
||||
assert.equal(fs.existsSync(runDir), true, 'mpv still lists the retimed file');
|
||||
assert.equal(fs.existsSync(staleDir), false, 'stale dirs from old sessions are swept');
|
||||
assert.equal(fs.existsSync(playingDir), true, 'stale but referenced dirs are kept');
|
||||
|
||||
pruneRetainedSubsyncTempDirs(['/media/ep02.ja.srt']);
|
||||
pruneRetainedSubsyncTempDirs(['/media/ep02.ja.srt'], { tmpRoot: isolatedTmp });
|
||||
assert.equal(fs.existsSync(runDir), false, 'dropped once mpv no longer lists it');
|
||||
} finally {
|
||||
if (previousTmpDir === undefined) delete process.env.TMPDIR;
|
||||
else process.env.TMPDIR = previousTmpDir;
|
||||
fs.rmSync(isolatedTmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user