mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[bugfix-560] don't move old installation path if it doesn't exist
This commit is contained in:
@@ -23,5 +23,5 @@ ipc.on("bs-installer.install-path", (_, reply) => {
|
||||
|
||||
ipc.on("bs-installer.set-install-path", (args, reply) => {
|
||||
const service = InstallationLocationService.getInstance();
|
||||
reply(from(service.setInstallationDirectory(args)));
|
||||
reply(from(service.setInstallationDirectory(args.path, args.move)));
|
||||
});
|
||||
|
||||
@@ -40,18 +40,22 @@ export class InstallationLocationService {
|
||||
this.updateListeners.forEach(listener => listener());
|
||||
}
|
||||
|
||||
public async setInstallationDirectory(newDir: string): Promise<string> {
|
||||
/**
|
||||
* @param move - if true, move the old installation path to the path param
|
||||
*/
|
||||
public async setInstallationDirectory(newDir: string, move: boolean): Promise<string> {
|
||||
newDir = path.basename(newDir) === this.INSTALLATION_FOLDER ? path.join(newDir, "..") : newDir;
|
||||
const oldDir = this.installationDirectory();
|
||||
|
||||
await ensureFolderExist(oldDir);
|
||||
await copyDirectoryWithJunctions(oldDir, path.join(newDir, this.INSTALLATION_FOLDER), { overwrite: true });
|
||||
if (move) {
|
||||
const oldDir = this.installationDirectory();
|
||||
await ensureFolderExist(oldDir);
|
||||
await copyDirectoryWithJunctions(oldDir, path.join(newDir, this.INSTALLATION_FOLDER), { overwrite: true });
|
||||
deleteFolder(oldDir);
|
||||
}
|
||||
|
||||
this._installationDirectory = newDir;
|
||||
this.staticConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
|
||||
|
||||
deleteFolder(oldDir);
|
||||
|
||||
return this.installationDirectory();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user