mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
fix(openfleet): keep the settings file's exact mode across a rewrite (#240)
writeSettings created its temp file with the original mode, but the create mode is filtered through the umask, so a rewrite could leave the settings file with fewer permission bits than it had. It now chmods the temp file to the mode outright before the rename. Found and fixed by a moshcode work agent (fleet sweep); verify: npx vitest run ./src/hooks-install.test.ts (packages/openfleet). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ef35139f04
commit
5c0e38a5c9
1 changed files with 4 additions and 1 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* command is marker enough.
|
||||
*/
|
||||
|
||||
import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
||||
import { chmodSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import type { Env } from "./store.js";
|
||||
|
|
@ -117,6 +117,9 @@ export function writeSettings(file: string, data: Json, mode: number): void {
|
|||
// would otherwise leave it truncated.
|
||||
const tmp = `${file}.logicsrc-${process.pid}`;
|
||||
writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { mode });
|
||||
// The create mode is filtered through the umask; set it outright so the
|
||||
// file keeps exactly the mode it had.
|
||||
chmodSync(tmp, mode);
|
||||
renameSync(tmp, file);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue