Skip to content

Commit

Permalink
Merge pull request #326 from Zagrios/bugfix/bsm-was-using-the-parent-…
Browse files Browse the repository at this point in the history
…of-bs-content-folder

[bugfix] fix of using the parent of installation folder when it was set in the config
  • Loading branch information
Zagrios authored Sep 23, 2023
2 parents 7378b23 + 8efe5be commit 120470d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/main/services/installation-location.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export class InstallationLocationService {
}

public async setInstallationDirectory(newDir: string): Promise<string> {
newDir = path.basename(newDir) === this.INSTALLATION_FOLDER ? newDir : path.join(newDir, this.INSTALLATION_FOLDER);
newDir = path.basename(newDir) === this.INSTALLATION_FOLDER ? path.join(newDir, "..") : newDir;
const oldDir = await this.installationDirectory();

await ensureFolderExist(oldDir);
await copyDirectoryWithJunctions(oldDir, newDir, { overwrite: true });
await copyDirectoryWithJunctions(oldDir, path.join(newDir, this.INSTALLATION_FOLDER), { overwrite: true });

this._installationDirectory = newDir;
this.installPathConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
Expand All @@ -57,23 +57,27 @@ export class InstallationLocationService {
}

public async installationDirectory(): Promise<string> {
if(this._installationDirectory) {
return this._installationDirectory;
}

if(this.installPathConfig.has(this.STORE_INSTALLATION_PATH_KEY)) {
this._installationDirectory = this.installPathConfig.get(this.STORE_INSTALLATION_PATH_KEY) as string;
return this._installationDirectory;
}

const oldPath = path.join(app.getPath("documents"), this.INSTALLATION_FOLDER);
if(await pathExist(oldPath)){
this._installationDirectory = oldPath;
return this._installationDirectory;
}
const installParentPath = async () => {
if(this._installationDirectory) {
return this._installationDirectory;
}

if(this.installPathConfig.has(this.STORE_INSTALLATION_PATH_KEY)) {
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)){
return app.getPath("documents");
}

return app.getPath("home");
};

this._installationDirectory = await installParentPath();

this._installationDirectory = path.join(app.getPath("home"), this.INSTALLATION_FOLDER);
return this._installationDirectory;
return path.join(this._installationDirectory, this.INSTALLATION_FOLDER);
}

public async versionsDirectory(): Promise<string> {
Expand Down

0 comments on commit 120470d

Please sign in to comment.