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 creates its temp file exclusively

EtienneLescotc41a416c8d31
diff --git a/electron/cli/cliMain.ts b/electron/cli/cliMain.ts
index 3f11bb9de..f56980c3f 100644
--- a/electron/cli/cliMain.ts
+++ b/electron/cli/cliMain.ts
@@ -468,11 +468,14 @@ export function runCli(command: CliCommand): void {
const target = await fs.realpath(command.projectPath);
const { mode } = await fs.stat(target);
const tmpPath = `${target}.${process.pid}.tmp`;
+ // "wx": a file or symlink already at that path is refused, never written through,
+ // and so never removed below either.
+ await fs.writeFile(tmpPath, JSON.stringify(result.projectData, null, 2), {
+ encoding: "utf8",
+ mode: 0o600,
+ flag: "wx",
+ });
try {
- await fs.writeFile(tmpPath, JSON.stringify(result.projectData, null, 2), {
- encoding: "utf8",
- mode: 0o600,
- });
await fs.chmod(tmpPath, mode & 0o777);
const current = await fs.readFile(target, "utf8").catch(() => null);
if (current !== captionsSource) {