Skip to content

Commit c41a416

Browse files
committed
fix(cli): captions creates its temp file exclusively
1 parent a6255f8 commit c41a416

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎electron/cli/cliMain.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,14 @@ export function runCli(command: CliCommand): void {
468468
const target = await fs.realpath(command.projectPath);
469469
const { mode } = await fs.stat(target);
470470
const tmpPath = `${target}.${process.pid}.tmp`;
471+
// "wx": a file or symlink already at that path is refused, never written through,
472+
// and so never removed below either.
473+
await fs.writeFile(tmpPath, JSON.stringify(result.projectData, null, 2), {
474+
encoding: "utf8",
475+
mode: 0o600,
476+
flag: "wx",
477+
});
471478
try {
472-
await fs.writeFile(tmpPath, JSON.stringify(result.projectData, null, 2), {
473-
encoding: "utf8",
474-
mode: 0o600,
475-
});
476479
await fs.chmod(tmpPath, mode & 0o777);
477480
const current = await fs.readFile(target, "utf8").catch(() => null);
478481
if (current !== captionsSource) {

0 commit comments

Comments
 (0)