mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix timing issue with fileNameMigration
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
daa68d96b9
commit
86815ae9f5
@ -6,12 +6,17 @@ export async function fileNameMigration() {
|
|||||||
const userDataPath = (app || remote.app).getPath("userData");
|
const userDataPath = (app || remote.app).getPath("userData");
|
||||||
const configJsonPath = path.join(userDataPath, "config.json");
|
const configJsonPath = path.join(userDataPath, "config.json");
|
||||||
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
const lensUserStoreJsonPath = path.join(userDataPath, "lens-user-store.json");
|
||||||
const [configJsonExists, lensUserStoreJsonExists] = await Promise.all([
|
|
||||||
fse.pathExists(configJsonPath),
|
|
||||||
fse.pathExists(lensUserStoreJsonPath),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (configJsonExists && !lensUserStoreJsonExists) {
|
try {
|
||||||
await fse.move(configJsonPath, lensUserStoreJsonPath);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user