summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2026-03-07 18:48:13 -0500
committerDax Raad <[email protected]>2026-03-07 18:53:29 -0500
commit2230c3c40136746c88e781cff613037e6d958d8e (patch)
tree5cddde39f2eacbc60fc0836169a542f1b155a48e
parent1b494e508714275737417315f09bcf79d25cbc65 (diff)
downloadopencode-2230c3c40136746c88e781cff613037e6d958d8e.tar.gz
opencode-2230c3c40136746c88e781cff613037e6d958d8e.zip
core: allow beta channel to share database with stable channel
-rw-r--r--packages/opencode/src/storage/db.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/packages/opencode/src/storage/db.ts b/packages/opencode/src/storage/db.ts
index 3e584d31a..cd920a890 100644
--- a/packages/opencode/src/storage/db.ts
+++ b/packages/opencode/src/storage/db.ts
@@ -14,6 +14,7 @@ import { readFileSync, readdirSync, existsSync } from "fs"
import * as schema from "./schema"
import { Installation } from "../installation"
import { Flag } from "../flag/flag"
+import { iife } from "@/util/iife"
declare const OPENCODE_MIGRATIONS: { sql: string; timestamp: number; name: string }[] | undefined
@@ -27,15 +28,13 @@ export const NotFoundError = NamedError.create(
const log = Log.create({ service: "db" })
export namespace Database {
- export function file(channel: string) {
- if (channel === "latest" || Flag.OPENCODE_DISABLE_CHANNEL_DB) return "opencode.db"
+ export const Path = iife(() => {
+ const channel = Installation.CHANNEL
+ if (["latest", "beta"].includes(channel) || Flag.OPENCODE_DISABLE_CHANNEL_DB)
+ return path.join(Global.Path.data, "opencode.db")
const safe = channel.replace(/[^a-zA-Z0-9._-]/g, "-")
- return `opencode-${safe}.db`
- }
-
- export const Path = (() => {
- return path.join(Global.Path.data, file(Installation.CHANNEL))
- })()
+ return path.join(Global.Path.data, `opencode-${safe}.db`)
+ })
type Schema = typeof schema
export type Transaction = SQLiteTransaction<"sync", void, Schema>