diff --git a/src/migrations/user-store/file-name-migration.ts b/src/migrations/user-store/file-name-migration.ts index dd2f46d0da..0abe6b280b 100644 --- a/src/migrations/user-store/file-name-migration.ts +++ b/src/migrations/user-store/file-name-migration.ts @@ -6,12 +6,17 @@ 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"); - const [configJsonExists, lensUserStoreJsonExists] = await Promise.all([ - fse.pathExists(configJsonPath), - fse.pathExists(lensUserStoreJsonPath), - ]); - if (configJsonExists && !lensUserStoreJsonExists) { + 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; + } } -} \ No newline at end of file +}