add user-store file name migration (#733)

Co-authored-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian MaltonandSebastian Malton authored and GitHub committed 2021-03-23 11:56:04 -04:00
1 parent 62c3501011
commit 0b99377feb
3 files changed
+39 -1

No files matched your search

@@ -0,0 +1,22 @@
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;
}
}
}
+5
View File
@@ -1,6 +1,11 @@
// User store migrations
import version210Beta4 from "./2.1.0-beta.4";
import { fileNameMigration } from "./file-name-migration";
export {
fileNameMigration
};
export default {
...version210Beta4,