Skip to content

Commit 6887a60

Browse files
committed
fix(cli): handle EACCES gracefully in checkMode during permission scan
When the config directory lacks execute permission, stat on child files (db, wal, shm) fails with EACCES instead of returning mode bits. Treat EACCES like ENOENT (skip the file) since the directory permission check will catch the root cause.
1 parent 587d8fd commit 6887a60

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/commands/cli/fix.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ async function checkMode(
6565
return { actualMode: mode };
6666
}
6767
} catch (error: unknown) {
68-
// Missing files aren't a permission problem (WAL/SHM created on demand)
69-
if (
70-
error instanceof Error &&
71-
(error as NodeJS.ErrnoException).code === "ENOENT"
72-
) {
68+
const code =
69+
error instanceof Error
70+
? (error as NodeJS.ErrnoException).code
71+
: undefined;
72+
// Missing files aren't a permission problem (WAL/SHM created on demand).
73+
// EACCES means the parent directory blocks stat — the directory check
74+
// will catch the root cause, so skip the individual file here.
75+
if (code === "ENOENT" || code === "EACCES") {
7376
return null;
7477
}
75-
// Unexpected filesystem error — re-throw so it surfaces to the user
76-
// and gets captured by the top-level Sentry error handler in bin.ts
7778
throw error;
7879
}
7980
return null;

0 commit comments

Comments
 (0)