mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(desktop): show onboarding when userData has an unrelated .dat file
This commit is contained in:
@@ -9,6 +9,7 @@ describe("hasExistingAppState", () => {
|
||||
test("recognizes state from an earlier OpenCode launch but not files Electron creates on a fresh install", () => {
|
||||
expect(hasExistingAppState([])).toBe(false)
|
||||
expect(hasExistingAppState([file("Local State"), directory("Crashpad")])).toBe(false)
|
||||
expect(hasExistingAppState([file("unrelated.dat")])).toBe(false)
|
||||
expect(hasExistingAppState([file("opencode.settings")])).toBe(true)
|
||||
expect(hasExistingAppState([file("opencode.global.dat")])).toBe(true)
|
||||
expect(hasExistingAppState([file("drafts.sqlite")])).toBe(true)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { isStoreFile } from "./legacy"
|
||||
|
||||
export function hasExistingAppState(entries: Array<{ name: string; directory: boolean }>) {
|
||||
return entries.some((entry) => {
|
||||
if (entry.name === "opencode.settings") return true
|
||||
|
||||
if (entry.name.endsWith(".dat")) return true
|
||||
if (isStoreFile(entry.name)) return true
|
||||
|
||||
if (entry.name === "drafts.sqlite") return true
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ export const importLegacyStores = Effect.fn("DesktopStorage.importLegacyStores")
|
||||
return { imported: rows.length, removed: candidates.map((file) => file.name) }
|
||||
})
|
||||
|
||||
function isStoreFile(name: string) {
|
||||
export function isStoreFile(name: string) {
|
||||
return name === "default.dat" || /^opencode\..+\.dat$/.test(name)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user