mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-19 05:58:01 +08:00
a8a8a3710d
`doInitLbug` unconditionally called `acquireInitLock`, which creates
`${dbPath}.init.lock` inside the workspace. On a Docker `:ro` bind
mount this fails with EROFS.
The init lock prevents a TOCTOU race during DB creation — read-only
opens never create databases and don't need it. Split the init path:
- Read-only: skip path cleanup, init lock, orphan sidecar removal,
and mkdir. Go straight to preflightLbugSidecars (allowQuarantine:
false) then openLbugConnection with readOnly: true.
- Writable: unchanged behavior (lock, cleanup, open).
- Shadow-replay recovery: catch EROFS/EACCES/EPERM from the writable
fallback in ensureReadOnlyConnectionUsable and surface an actionable
error instead of a raw filesystem exception.
Includes integration test verifying read-only open never creates
lbug.init.lock on disk.
Fixes #1783
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
/**
|
|
* Integration Tests: read-only doInitLbug path (#1783)
|
|
*
|
|
* Verifies that read-only LadybugDB opens skip filesystem mutations
|
|
* (init lock, orphan sidecar cleanup, mkdir) so they work on read-only
|
|
* filesystems such as Docker :ro bind mounts.
|
|
*/
|
|
import fs from 'fs/promises';
|
|
import { it, expect } from 'vitest';
|
|
import { withTestLbugDB } from '../helpers/test-indexed-db.js';
|
|
import { _initLockPathForTest } from '../../src/core/lbug/lbug-adapter.js';
|
|
|
|
withTestLbugDB('lbug-readonly-init', (handle) => {
|
|
it('read-only open never creates lbug.init.lock on disk', async () => {
|
|
const { dbPath } = handle;
|
|
const lockPath = _initLockPathForTest(dbPath);
|
|
|
|
const adapter = await import('../../src/core/lbug/lbug-adapter.js');
|
|
await adapter.closeLbug();
|
|
|
|
await expect(fs.access(lockPath)).rejects.toMatchObject({ code: 'ENOENT' });
|
|
|
|
await adapter.withLbugDb(dbPath, async () => {}, { readOnly: true });
|
|
|
|
await expect(fs.access(lockPath)).rejects.toMatchObject({ code: 'ENOENT' });
|
|
|
|
await adapter.closeLbug();
|
|
});
|
|
});
|