UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.38 kB
import{d as e,i as t,l as n,t as r,u as i}from"./sqlite-readonly-sqlite-readonly-location-CrsaHxKY.mjs";import{nt as a}from"./sqlite-readonly-sqlite-database-admission-Bj6bmeyX.mjs";import{t as o,u as s}from"./sqlite-readonly-sqlite-source-handle-DKI8EMUs.mjs";import c from"node:fs";function tryInspectSqliteReadOnlyInProcess(e,a,s={}){let l=c.realpathSync.native(e),u;try{u=n(l)}catch(e){if(e instanceof r)return;throw e}let d=i(l),f=s.preserveSourceArtifacts===!0,p=!f&&s.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 o=a(e);return e.exec(`ROLLBACK;`),{value:o}};try{return o(l,`source`,read,{readOnlyShm:f})}catch(e){if(u===`wal`&&p&&s.snapshotAfterClosedWalFailure||f&&isSqliteCantOpenError(e))return;throw e}}function isSqliteCantOpenError(e){return a(e)===14}function requiresSqliteRollbackRecoveryInProcess(t){return o(t,`source`,n=>{try{return s(n),!1}catch(n){if(!e(t,n))throw n;return!0}})}export{tryInspectSqliteReadOnlyInProcess as n,requiresSqliteRollbackRecoveryInProcess as t};