mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 16:49:51 -07:00
fix(history-db): treat SQLITE_CANTOPEN as readonly WAL retry error
- Add `sqlite_cantopen` and `unable to open database file` to `isReadonlyWalRetryError` checks - Cover `SQLITE_CANTOPEN` case in test
This commit is contained in:
@@ -58,7 +58,9 @@ export function isReadonlyWalRetryError(error: unknown, dbPath: string): boolean
|
||||
return (
|
||||
text.includes('readonly') ||
|
||||
text.includes('read-only') ||
|
||||
text.includes('attempt to write a readonly database')
|
||||
text.includes('attempt to write a readonly database') ||
|
||||
text.includes('sqlite_cantopen') ||
|
||||
text.includes('unable to open database file')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +300,15 @@ test('isReadonlyWalRetryError only accepts readonly errors from WAL-mode databas
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isReadonlyWalRetryError(
|
||||
Object.assign(new Error('unable to open database file'), {
|
||||
code: 'SQLITE_CANTOPEN',
|
||||
}),
|
||||
walDbPath,
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isReadonlyWalRetryError(new Error('no such table: imm_sessions'), walDbPath),
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user