diff --git a/src/common/base-store.ts b/src/common/base-store.ts index 54f6d2a5a2..c5fc7383b1 100644 --- a/src/common/base-store.ts +++ b/src/common/base-store.ts @@ -46,6 +46,10 @@ export abstract class BaseStore extends Singleton { protected constructor(protected params: BaseStoreParams) { super(); makeObservable(this); + + if (ipcRenderer) { + params.migrations = undefined; // don't run migrations on renderer + } } /** diff --git a/src/common/user-store/user-store.ts b/src/common/user-store/user-store.ts index 8cababf3c6..1bd18e06e8 100644 --- a/src/common/user-store/user-store.ts +++ b/src/common/user-store/user-store.ts @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { app } from "electron"; +import { app, ipcMain } from "electron"; import semver from "semver"; import { action, computed, observable, reaction, makeObservable } from "mobx"; import { BaseStore } from "../base-store"; @@ -48,7 +48,11 @@ export class UserStore extends BaseStore /* implements UserStore }); makeObservable(this); - fileNameMigration(); + + if (ipcMain) { + fileNameMigration(); + } + this.load(); } diff --git a/src/migrations/user-store/5.0.3-beta.1.ts b/src/migrations/user-store/5.0.3-beta.1.ts index ea1c9dde52..05a1767f08 100644 --- a/src/migrations/user-store/5.0.3-beta.1.ts +++ b/src/migrations/user-store/5.0.3-beta.1.ts @@ -19,21 +19,22 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +import { app } from "electron"; import { existsSync, readFileSync } from "fs"; import path from "path"; import os from "os"; import type { ClusterStoreModel } from "../../common/cluster-store"; import type { KubeconfigSyncEntry, UserPreferencesModel } from "../../common/user-store"; import { MigrationDeclaration, migrationLog } from "../helpers"; -import { getPath, isLogicalChildPath, storedKubeConfigFolder } from "../../common/utils"; +import { isLogicalChildPath, storedKubeConfigFolder } from "../../common/utils"; export default { version: "5.0.3-beta.1", run(store) { try { const { syncKubeconfigEntries = [], ...preferences }: UserPreferencesModel = store.get("preferences") ?? {}; - const { clusters = [] }: ClusterStoreModel = JSON.parse(readFileSync(path.resolve(getPath("userData"), "lens-cluster-store.json"), "utf-8")) ?? {}; - const extensionDataDir = path.resolve(getPath("userData"), "extension_data"); + const { clusters = [] }: ClusterStoreModel = JSON.parse(readFileSync(path.resolve(app.getPath("userData"), "lens-cluster-store.json"), "utf-8")) ?? {}; + const extensionDataDir = path.resolve(app.getPath("userData"), "extension_data"); const syncPaths = new Set(syncKubeconfigEntries.map(s => s.filePath)); syncPaths.add(path.join(os.homedir(), ".kube")); diff --git a/src/migrations/user-store/file-name-migration.ts b/src/migrations/user-store/file-name-migration.ts index 10d7a7c99b..932e542642 100644 --- a/src/migrations/user-store/file-name-migration.ts +++ b/src/migrations/user-store/file-name-migration.ts @@ -19,12 +19,12 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +import { app } from "electron"; import fse from "fs-extra"; import path from "path"; -import { getPath } from "../../common/utils/getPath"; export function fileNameMigration() { - const userDataPath = getPath("userData"); + const userDataPath = app.getPath("userData"); const configJsonPath = path.join(userDataPath, "config.json"); const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");