fix(session-persistence): address permission review

This commit is contained in:
Yichen Jiang
2026-07-17 10:47:32 +08:00
parent 96975f3840
commit ac893f97bb
4 changed files with 16 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
import { afterEach, describe, expect, it } from 'vitest'
import { Context } from 'cordis'
import { existsSync } from 'node:fs'
import { chmod, mkdtemp, mkdir, rm, stat, writeFile } from 'node:fs/promises'
import { chmod, mkdtemp, rm, stat, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { dirname, join } from 'node:path'
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
@@ -379,19 +379,12 @@ describe('SessionPersistenceSqlite: edge cases', () => {
await fiber.dispose()
})
it('surfaces database pre-creation errors other than an existing file', async () => {
if (process.platform === 'win32') return
it('surfaces database pre-creation errors independently of process privileges', async () => {
const path = await freshDbPath()
const blocked = join(dirname(path), 'blocked')
await mkdir(blocked, { mode: 0o500 })
const b = await backend(join(blocked, 'sessions.db'))
const b = await backend(`${path}\0`)
try {
await expect(b.ctx.sessionPersistence.list()).rejects.toMatchObject({ code: 'EACCES' })
await b.dispose()
} finally {
await chmod(blocked, 0o700)
}
await expect(b.ctx.sessionPersistence.list()).rejects.toMatchObject({ code: 'ERR_INVALID_ARG_VALUE' })
await b.dispose()
})
it('append rolls back and rethrows when an event INSERT fails inside the transaction', async () => {