withDatabaseCopy (browser-import/chrome-store.ts)

travel-agent · packages/desktop/src/browser-import/chrome-store.ts · typescript · Apache-2.0
database

Safely reads locked Chrome SQLite databases by copying them with WAL sidecars to a temp directory.

// Source: https://github.com/Prism-Shadow/travel-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Reading the other browser's SQLite files without disturbing them.
 *
 * Everything here copies before it reads. Three reasons, and the third is the one that actually
 * bites:
 *
 * 1. Chrome holds `Cookies` and `History` open. On Windows the lock is mandatory and opening the
 *    original fails outright; on Unix it succeeds and then returns `SQLITE_BUSY` partway through.
 * 2. Opening a live database read-write — which any SQLite handle may do while recovering a hot
 *    journal — can *modify another application's file*. Nothing in an import is worth that risk.
 * 3. *

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key