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();
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ export function SettingsPage() {
|
||||
|
||||
notificationService.notifySuccess({ title: "notifications.settings.move-folder.success.titles.transfer-started", desc: "notifications.settings.move-folder.success.descs.transfer-started" });
|
||||
|
||||
lastValueFrom(installationLocationService.setInstallationFolder(fileChooserRes.filePaths[0])).then(res => {
|
||||
lastValueFrom(installationLocationService.setInstallationFolder(fileChooserRes.filePaths[0], true)).then(res => {
|
||||
|
||||
progressBarService.complete();
|
||||
progressBarService.hide(true);
|
||||
|
||||
@@ -23,7 +23,13 @@ export class InstallationLocationService {
|
||||
return lastValueFrom(this.ipcService.sendV2("bs-installer.install-path"));
|
||||
}
|
||||
|
||||
public setInstallationFolder(path: string): Observable<string> {
|
||||
return this.ipcService.sendV2("bs-installer.set-install-path", path);
|
||||
/**
|
||||
* @param move - if true, move the old installation path to the path param
|
||||
*/
|
||||
public setInstallationFolder(path: string, move: boolean): Observable<string> {
|
||||
return this.ipcService.sendV2(
|
||||
"bs-installer.set-install-path",
|
||||
{ path, move }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class SetupService {
|
||||
{ closable: false }
|
||||
);
|
||||
|
||||
await lastValueFrom(this.installationLocationService.setInstallationFolder(modalResponse.data.installPath));
|
||||
await lastValueFrom(this.installationLocationService.setInstallationFolder(modalResponse.data.installPath, false));
|
||||
|
||||
// Refresh the versions tab
|
||||
await this.versionManagerService.askInstalledVersions();
|
||||
|
||||
@@ -46,7 +46,7 @@ export interface IpcChannelMapping {
|
||||
"bs-installer.folder-exists": { request: void, response: boolean };
|
||||
"bs-installer.default-install-path": { request: void, response: string };
|
||||
"bs-installer.install-path": { request: void, response: string};
|
||||
"bs-installer.set-install-path": { request: string, response: string};
|
||||
"bs-installer.set-install-path": { request: { path: string, move: boolean }, response: string};
|
||||
|
||||
/* ** bs-launcher-ipcs ** */
|
||||
"create-launch-shortcut": { request: LaunchOption, response: boolean };
|
||||
|
||||
Reference in New Issue
Block a user