fix incorrect config directory by lazily loading electron-store (#23373)
This commit is contained in:
parent
40ba8f3570
commit
b34ca44abe
3 changed files with 14 additions and 12 deletions
|
|
@ -4,6 +4,10 @@ import { SETTINGS_STORE } from "./constants"
|
|||
|
||||
const cache = new Map<string, Store>()
|
||||
|
||||
// We cannot instantiate the electron-store at module load time because
|
||||
// module import hoisting causes this to run before app.setPath("userData", ...)
|
||||
// in index.ts has executed, which would result in files being written to the default directory
|
||||
// (e.g. bad: %APPDATA%\@opencode-ai\desktop-electron\opencode.settings vs good: %APPDATA%\ai.opencode.desktop.dev\opencode.settings).
|
||||
export function getStore(name = SETTINGS_STORE) {
|
||||
const cached = cache.get(name)
|
||||
if (cached) return cached
|
||||
|
|
@ -11,5 +15,3 @@ export function getStore(name = SETTINGS_STORE) {
|
|||
cache.set(name, next)
|
||||
return next
|
||||
}
|
||||
|
||||
export const store = getStore(SETTINGS_STORE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue