[bugfix] handle unable to get documents path error

This commit is contained in:
MathieuG-P
2024-03-04 13:29:23 +01:00
parent 590daf3be2
commit eb76bb5df0
@@ -2,6 +2,8 @@ import path from "path";
import { app } from "electron";
import ElectronStore from "electron-store";
import { copyDirectoryWithJunctions, deleteFolder, ensureFolderExist, pathExist } from "../helpers/fs.helpers";
import { tryit } from "../../shared/helpers/error.helpers";
import { pathExistsSync } from "fs-extra";
export class InstallationLocationService {
private static instance: InstallationLocationService;
@@ -67,8 +69,8 @@ export class InstallationLocationService {
return this.installPathConfig.get(this.STORE_INSTALLATION_PATH_KEY) as string;
}
const oldPath = path.join(app.getPath("documents"), this.INSTALLATION_FOLDER);
if(await pathExist(oldPath)){
const { result: oldPath } = tryit(() => path.join(app.getPath("documents"), this.INSTALLATION_FOLDER));
if(oldPath && pathExistsSync(oldPath)){
return app.getPath("documents");
}