Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(db): preserve legacy SQLite database path on Windows to prevent data loss (#1973)

diegosouzapw80d52d9a7735
diff --git a/src/lib/dataPaths.ts b/src/lib/dataPaths.ts
index 24e7e8338a..3152265828 100644
--- a/src/lib/dataPaths.ts
+++ b/src/lib/dataPaths.ts
@@ -1,5 +1,6 @@
import path from "path";
import os from "os";
+import fs from "fs";
export const APP_NAME = "omniroute";
@@ -33,6 +34,18 @@ export function getLegacyDotDataDir() {
export function getDefaultDataDir() {
const homeDir = safeHomeDir();
+ const legacyDir = getLegacyDotDataDir();
+
+ // Preserve legacy path if it exists to avoid data loss on updates (e.g., Windows migration)
+ if (fs.existsSync(legacyDir)) {
+ try {
+ if (fs.statSync(legacyDir).isDirectory()) {
+ return legacyDir;
+ }
+ } catch {
+ // Ignore stat errors
+ }
+ }
if (process.platform === "win32") {
const appData = process.env.APPDATA || path.join(homeDir, "AppData", "Roaming");
@@ -45,7 +58,7 @@ export function getDefaultDataDir() {
return path.join(xdgConfigHome, APP_NAME);
}
- return getLegacyDotDataDir();
+ return legacyDir;
}
export function resolveDataDir({ isCloud = false }: { isCloud?: boolean } = {}): string {