Skip to content

Commit 3a54b1a

Browse files
committed
fix(ui): avoid tmp dir fs.constants access at import time
1 parent c186176 commit 3a54b1a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/infra/tmp-openclaw-dir.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import os from "node:os";
33
import path from "node:path";
44

55
export const POSIX_OPENCLAW_TMP_DIR = "/tmp/openclaw";
6-
const TMP_DIR_ACCESS_MODE = fs.constants.W_OK | fs.constants.X_OK;
6+
7+
function getTmpDirAccessMode(): number {
8+
return fs.constants.W_OK | fs.constants.X_OK;
9+
}
710

811
type ResolvePreferredOpenClawTmpDirOptions = {
912
accessSync?: (path: string, mode?: number) => void;
@@ -86,7 +89,7 @@ export function resolvePreferredOpenClawTmpDir(
8689
if (!isTrustedTmpDir(candidate)) {
8790
return "invalid";
8891
}
89-
accessSync(candidatePath, TMP_DIR_ACCESS_MODE);
92+
accessSync(candidatePath, getTmpDirAccessMode());
9093
return "available";
9194
} catch (err) {
9295
if (isNodeErrorWithCode(err, "ENOENT")) {
@@ -152,7 +155,7 @@ export function resolvePreferredOpenClawTmpDir(
152155
}
153156

154157
try {
155-
accessSync("/tmp", TMP_DIR_ACCESS_MODE);
158+
accessSync("/tmp", getTmpDirAccessMode());
156159
// Create with a safe default; subsequent callers expect it exists.
157160
mkdirSync(POSIX_OPENCLAW_TMP_DIR, { recursive: true, mode: 0o700 });
158161
chmodSync(POSIX_OPENCLAW_TMP_DIR, 0o700);

0 commit comments

Comments
 (0)