Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(cli): captions writes nothing over a project saved while it transcribed

EtienneLescot37f2a34fc5cd
diff --git a/electron/cli/cliMain.ts b/electron/cli/cliMain.ts
index 9e1d68825..d756756d1 100644
--- a/electron/cli/cliMain.ts
+++ b/electron/cli/cliMain.ts
@@ -408,6 +408,13 @@ export function runCli(command: CliCommand): void {
setupRecordStopSignals(stop);
}
+ // The project as the captions runner reads it. Transcribing takes minutes; a save made
+ // meanwhile must not be lost under the runner's older copy.
+ const captionsSource =
+ command.kind === "captions"
+ ? await fs.readFile(command.projectPath, "utf8").catch(() => null)
+ : null;
+
milestone("cli ipc registered; starting the runner");
const run = runners.start(command, {
onRequest: () => milestone("renderer asked for the request"),
@@ -453,6 +460,12 @@ export function runCli(command: CliCommand): void {
}
}
if (result.success && command.kind === "captions" && result.projectData !== undefined) {
+ const current = await fs.readFile(command.projectPath, "utf8").catch(() => null);
+ if (current !== captionsSource) {
+ throw new Error(
+ `${command.projectPath} changed while it was being captioned, so nothing was written. Run captions again.`,
+ );
+ }
await writeProjectFile(command.projectPath, result.projectData);
}
// -o writes where no wrapper can redirect. stdout itself is fine --