openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.05 kB
JavaScript
import{d as e,i as t,l as n,t as r,u as i}from"./sqlite-readonly-sqlite-readonly-location-CKoGOncu.mjs";import{Nt as a}from"./sqlite-readonly-node-sqlite-u3RAlsBE.mjs";import o from"node:fs";function tryInspectSqliteReadOnlyInProcess(a,s,c={}){let l=o.realpathSync.native(a),u;try{u=n(l)}catch(e){if(e instanceof r)return;throw e}let d=i(l),f=c.preserveSourceArtifacts===!0,p=!f&&c.allowClosedWal&&!d.wal&&!d.shm&&!d.journal;if(u===`empty`||u===`wal`&&!(d.wal&&d.shm)&&!p||f&&(u!==`wal`||d.journal))return;let read=e=>{try{e.exec(`PRAGMA busy_timeout = 30000; PRAGMA trusted_schema = OFF; BEGIN;`),e.prepare(`PRAGMA schema_version;`).get()}catch(e){let a;try{a=n(l)}catch(e){if(e instanceof r)return;throw e}let o=i(l);if(a===`wal`&&!(o.wal&&o.shm)||a===`rollback`&&o.journal&&t(e)||f&&t(e))return;throw e}let a=s(e);return e.exec(`ROLLBACK;`),{value:a}};try{return e(l,`source`,read,{readOnlyShm:f})}catch(e){if(f&&isSqliteCantOpenError(e))return;throw e}}function isSqliteCantOpenError(e){return a(e)===14}export{tryInspectSqliteReadOnlyInProcess as t};