Skip to content

Commit 192234f

Browse files
ashu17706claude
andcommitted
fix(db): handle Windows mkdir edge case for current directory
On Windows, mkdirSync('.') throws EEXIST error. Skip mkdir when dirname returns '.' and wrap in try-catch as defensive measure. Fixes Windows test failure in CI. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent c0034e6 commit 192234f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/db.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ export function getDb(path?: string): Database {
2424
const dbPath = path || QMD_DB_PATH;
2525
// Ensure parent directory exists before creating database file
2626
const dbDir = dirname(dbPath);
27-
mkdirSync(dbDir, { recursive: true });
27+
if (dbDir !== ".") {
28+
try {
29+
mkdirSync(dbDir, { recursive: true });
30+
} catch {
31+
// Directory might already exist or be inaccessible (unlikely in normal cases)
32+
}
33+
}
2834
_db = new Database(dbPath);
2935
_db.exec("PRAGMA journal_mode = WAL");
3036
_db.exec("PRAGMA foreign_keys = ON");

0 commit comments

Comments
 (0)