| @@ -3,6 +3,7 @@ import { createClient, type Client } from "@libsql/client"; · 2 unmodified lines |
| 3 | 3 | import { Data } from "effect"; |
| 4 | 4 | import { mkdirSync, realpathSync } from "node:fs"; |
| 5 | 5 | import { join, resolve } from "node:path"; |
| 6 | +import { pathToFileURL } from "node:url"; |
| 6 | 7 | |
| 7 | 8 | export class DataDirOwnershipHeld extends Data.TaggedError("DataDirOwnershipHeld")<{ |
| 8 | 9 | readonly message: string; |
| @@ -17,7 +18,7 @@ export interface DataDirOwnership { · 8 unmodified lines |
| 17 | 18 | |
| 18 | 19 | const LOCK_DATABASE_FILENAME = "data.db.owner-lock"; |
| 19 | 20 | |
| 20 | | −const toLibsqlFileUrl = (path: string): string => `file:${resolve(path)}`; |
| 21 | +const toLibsqlFileUrl = (path: string): string => pathToFileURL(resolve(path)).href; |
| 21 | 22 | |
| 22 | 23 | const ownerLockPath = (dataDir: string): string => { |
| 23 | 24 | mkdirSync(dataDir, { recursive: true }); |
| @@ -63,9 +64,7 @@ const configureOwnershipLockClient = async (client: Client): Promise<void> => { · 39 unmodified lines |
| 63 | 64 | await client.execute("PRAGMA journal_mode = DELETE"); |
| 64 | 65 | }; |
| 65 | 66 | |
| 66 | | −export const acquireDataDirOwnership = async ( |
| 67 | | − dataDir: string, |
| 68 | | −): Promise<DataDirOwnership> => { |
| 67 | +export const acquireDataDirOwnership = async (dataDir: string): Promise<DataDirOwnership> => { |
| 69 | 68 | const lockPath = ownerLockPath(dataDir); |
| 70 | 69 | const client = openOwnershipLockClient(lockPath); |
| 71 | 70 | |