Unverified Commit 0b99377f authored by Sebastian Malton's avatar Sebastian Malton Committed by GitHub
Browse files

add user-store file name migration (#733)

Co-authored-by: default avatarSebastian Malton <smalton@mirantis.com>
parent 62c35010
master allowed-resources api-manager-claenup asdasd ban-circular-deps better-release-script bug/port-forward-missing build-flatpak bundled-extensions-update catalog-entity-detail-registry cleanup-pod-details-container consolidate-running-of-setups-on-application-start dependabot/npm_and_yarn/react-select-5.3.2 dependabot/npm_and_yarn/react-window-1.8.7 dependabot/npm_and_yarn/types/node-14.18.16 dependabot/npm_and_yarn/types/webpack-env-1.16.4 di-stores disposer-for-singletons docs/api-all-exported electron-11.4.3 electron-12 enhancement-node-vertical-metric-bars enhancement/group-app-preferences-by-extension ensure-listref-current entity-settings extension-auto-update extension-dir extension-discovery-changes extension-startup extensions/lens-version-check feat/add-bg-to-cluster-status feat/add-tests-for-main-extension-api-and-catalog-entity-registry feat/capture-logger-error feat/capture-winston-logger feat/lazy-load-compoment feat/new-api feature/auto-update feature/catalog-helm-repos feature/context-providers feature/kube-api-manager feature/navigate-back-ui-button fix-NamespaceSelect-gradients fix-change-os-theme-crash fix-concurrent-access fix-lint-error fix-linter-errors fix-local-shell-session fix-namespace-filter-select fix-optimise-update-events-from-buffer fix-reload-list-items-on-mount fix-remove-watch-flush-headers fix-reseting-select-value fix-resource-applier fix-sync-open fix/allown-entity-id fix/blank-disabled-select-option fix/consistent-inputs fix/log-store-loading fix/node-shell-fail fix/ns-selector-performance-issue fix/pod-logs-storage fix/rewatch-if-resume fix/search_input_autofocus front-end-routes-ocp front-end-routes-ocp-2 front-end-routes-ocp-3 fuzz-tests global-watch hackweek/multiple-windows helm-repo-manager helm-repo-manager-removal helm-routes improve-metrics-queries improved-categories issue-1909 issue-2549 issue-2648 issue-2727 issue-3126 issue-3232 issue-3276 issue-3374 issue-3498 issue-3797 issue-3896 issue-4633 issue-4766 issue-4829 issue-4997 issue-5141 issue-5165 issue-5173 issue-5177 issue-5238 menu_enhancement mobx-6.2 more-places-to-check-for-updates move-docs native-menus port-forward-pod-deleted prometheus/victoria-metrics-single reactive-table refactor-settings-layout-styles release/v4.2 release/v5.0.0-rc.0 release/v5.2 release/v5.2.4 release/v5.2.7-beta.0 release/v5.3 release/v5.4 remove-font-icons remove-in-app-release-notes remove-unused-telemetry resizable_table_columns run-npm-publish-master-always set-build-version show-extension-preferences-in-separate-page single-logger squashed-update-injectable strict-mode temporary-manual-update-notification test/remove-sentry testing/issue-4314 testing/virtual-select tidy-hiddenTableColumns top-bar-registry turn-on-strict ui-table-empty-state-lines ui-tweaks update-bundled-extensions update-electon-builder-to-3-0-8 update-locks upgrade-typedoc-to-0.20 validate-cluster-model verify-quit-events websocket-catalog-sync welcome-banners-rounded-corners welcome-menu-registry v5.5.0-beta.0 v5.4.6 v5.4.5 v5.4.4 v5.4.3 v5.4.2 v5.4.1 v5.4.0 v5.4.0-beta.5 v5.4.0-beta.4 v5.4.0-beta.3 v5.4.0-beta.2 v5.4.0-beta.1 v5.4.0-beta.0 v5.4.0-alpha.1 v5.4.0-alpha.0 v5.3.4 v5.3.3 v5.3.2 v5.3.1 v5.3.0 v5.3.0-beta.4 v5.3.0-beta.3 v5.3.0-beta.2 v5.3.0-beta.1 v5.3.0-beta.0 v5.3.0-alpha.11 v5.3.0-alpha.10 v5.3.0-alpha.9 v5.3.0-alpha.8 v5.3.0-alpha.7 v5.3.0-alpha.6 v5.3.0-alpha.5 v5.3.0-alpha.4 v5.3.0-alpha.3 v5.3.0-alpha.2 v5.3.0-alpha.1 v5.3.0-alpha.0 v5.2.7 v5.2.6 v5.2.6-beta.1 v5.2.6-beta.0 v5.2.5 v5.2.4 v5.2.3 v5.2.2 v5.2.1 v5.2.0 v5.2.0-rc.1 v5.2.0-beta.4 v5.2.0-beta.3 v5.2.0-beta.2 v5.2.0-beta.1 v5.1.3 v5.1.2 v5.1.1 v5.1.0 v5.1.0-beta.2 v5.1.0-beta.1 v5.0.2 v5.0.1 v5.0.0 v5.0.0-rc.0 v5.0.0-beta.13 v5.0.0-beta.12 v5.0.0-beta.11 v5.0.0-beta.10 v5.0.0-beta.9 v5.0.0-beta.8 v5.0.0-beta.7 v5.0.0-beta.6 v5.0.0-beta.5 v5.0.0-beta.4 v5.0.0-beta.3 v5.0.0-beta.2 v5.0.0-beta.1 v5.0.0-alpha.4 v5.0.0-alpha.3 v5.0.0-alpha.2 v5.0.0-alpha.1 v4.2.5 v4.2.4 v4.2.3 v4.2.2 v4.2.1 v4.2.0 v4.2.0-rc.3 v4.2.0-rc.2
No related merge requests found
Showing with 39 additions and 1 deletion
+39 -1
......@@ -10,6 +10,7 @@ import { kubeConfigDefaultPath, loadConfig } from "./kube-helpers";
import { appEventBus } from "./event-bus";
import logger from "../main/logger";
import path from "path";
import { fileNameMigration } from "../migrations/user-store";
export interface UserStoreModel {
kubeConfigPath: string;
......@@ -37,7 +38,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
private constructor() {
super({
// configName: "lens-user-store", // todo: migrate from default "config.json"
configName: "lens-user-store",
migrations,
});
......@@ -85,6 +86,16 @@ export class UserStore extends BaseStore<UserStoreModel> {
}
}
async load(): Promise<void> {
/**
* This has to be here before the call to `new Config` in `super.load()`
* as we have to make sure that file is in the expected place for that call
*/
await fileNameMigration();
return super.load();
}
get isNewVersion() {
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
}
......
import fse from "fs-extra";
import { app, remote } from "electron";
import path from "path";
export async function fileNameMigration() {
const userDataPath = (app || remote.app).getPath("userData");
const configJsonPath = path.join(userDataPath, "config.json");
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
try {
await fse.move(configJsonPath, lensUserStoreJsonPath);
} catch (error) {
if (error.code === "ENOENT" && error.path === configJsonPath) { // (No such file or directory)
return; // file already moved
} else if (error.message === "dest already exists.") {
await fse.remove(configJsonPath);
} else {
// pass other errors along
throw error;
}
}
}
// User store migrations
import version210Beta4 from "./2.1.0-beta.4";
import { fileNameMigration } from "./file-name-migration";
export {
fileNameMigration
};
export default {
...version210Beta4,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment