fix: create PGLite data dir before lock (#85)
This commit is contained in:
committed by
GitHub
parent
004ac6c66f
commit
adb02b7826
@@ -2,6 +2,12 @@
|
||||
|
||||
All notable changes to GBrain will be documented in this file.
|
||||
|
||||
## [0.9.2] - 2026-04-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Fresh local installs initialize cleanly again.** `gbrain init` now creates the local PGLite data directory before taking its advisory lock, so first-run setup no longer misreports a missing directory as a lock timeout.
|
||||
|
||||
## [0.9.1] - 2026-04-11
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gbrain",
|
||||
"version": "0.9.1",
|
||||
"version": "0.9.2",
|
||||
"description": "Postgres-native personal knowledge brain with hybrid RAG search",
|
||||
"type": "module",
|
||||
"main": "src/core/index.ts",
|
||||
|
||||
@@ -59,6 +59,8 @@ export async function acquireLock(dataDir: string | undefined, opts?: { timeoutM
|
||||
return { lockDir: '', acquired: true };
|
||||
}
|
||||
|
||||
mkdirSync(dataDir, { recursive: true });
|
||||
|
||||
const timeoutMs = opts?.timeoutMs ?? 30_000; // 30 second default timeout
|
||||
const startTime = Date.now();
|
||||
|
||||
|
||||
@@ -26,6 +26,18 @@ describe('pglite-lock', () => {
|
||||
expect(existsSync(join(TEST_DIR, '.gbrain-lock'))).toBe(false);
|
||||
});
|
||||
|
||||
test('creates missing data directory before acquiring lock', async () => {
|
||||
const missingDataDir = join(TEST_DIR, 'missing-data-dir');
|
||||
|
||||
const lock = await acquireLock(missingDataDir);
|
||||
expect(lock.acquired).toBe(true);
|
||||
expect(existsSync(missingDataDir)).toBe(true);
|
||||
expect(existsSync(join(missingDataDir, '.gbrain-lock'))).toBe(true);
|
||||
|
||||
await releaseLock(lock);
|
||||
expect(existsSync(join(missingDataDir, '.gbrain-lock'))).toBe(false);
|
||||
});
|
||||
|
||||
test('prevents concurrent lock acquisition', async () => {
|
||||
const lock1 = await acquireLock(TEST_DIR, { timeoutMs: 2000 });
|
||||
expect(lock1.acquired).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user