|
2 | 2 | import { existsSync, readFileSync } from "node:fs"; |
3 | 3 | import { z } from "zod"; |
4 | 4 | import { isBlockedObjectKey } from "../infra/prototype-keys.js"; |
5 | | -import { |
6 | | - openOpenClawStateDatabase, |
7 | | - runOpenClawStateWriteTransaction, |
8 | | -} from "../state/openclaw-state-db.js"; |
| 5 | +import { withOpenClawStateDatabaseReadOnly } from "../state/openclaw-state-db-readonly.js"; |
| 6 | +import { runOpenClawStateWriteTransaction } from "../state/openclaw-state-db.js"; |
9 | 7 | import { safeParseWithSchema } from "../utils/zod-parse.js"; |
10 | 8 | import { resolveCompatibilityHostVersion } from "../version.js"; |
11 | 9 | import { normalizePluginsConfig, resolveEffectiveEnableState } from "./config-state.js"; |
@@ -294,21 +292,20 @@ function readPersistedInstalledPluginIndexFromSqlite( |
294 | 292 | return null; |
295 | 293 | } |
296 | 294 | try { |
297 | | - const database = openOpenClawStateDatabase( |
298 | | - resolveInstalledPluginIndexStateDatabaseOptions(options), |
299 | | - ); |
300 | | - const row = database.db |
301 | | - .prepare( |
302 | | - ` |
303 | | - SELECT version, warning, host_contract_version, compat_registry_version, |
304 | | - migration_version, policy_hash, generated_at_ms, refresh_reason, |
305 | | - install_records_json, plugins_json, diagnostics_json |
306 | | - FROM installed_plugin_index |
307 | | - WHERE index_key = ? |
308 | | - `, |
309 | | - ) |
310 | | - .get(INSTALLED_PLUGIN_INDEX_SQLITE_KEY) as InstalledPluginIndexSqliteRow | undefined; |
311 | | - return parseInstalledPluginIndexSqliteRow(row); |
| 295 | + return withOpenClawStateDatabaseReadOnly(({ db }) => { |
| 296 | + const row = db |
| 297 | + .prepare( |
| 298 | + ` |
| 299 | + SELECT version, warning, host_contract_version, compat_registry_version, |
| 300 | + migration_version, policy_hash, generated_at_ms, refresh_reason, |
| 301 | + install_records_json, plugins_json, diagnostics_json |
| 302 | + FROM installed_plugin_index |
| 303 | + WHERE index_key = ? |
| 304 | + `, |
| 305 | + ) |
| 306 | + .get(INSTALLED_PLUGIN_INDEX_SQLITE_KEY) as InstalledPluginIndexSqliteRow | undefined; |
| 307 | + return parseInstalledPluginIndexSqliteRow(row); |
| 308 | + }, resolveInstalledPluginIndexStateDatabaseOptions(options)); |
312 | 309 | } catch { |
313 | 310 | return null; |
314 | 311 | } |
|
0 commit comments