mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore-245] clean "setInstallationDirectory" process
This commit is contained in:
@@ -43,26 +43,20 @@ export class InstallationLocationService {
|
||||
this.updateListeners.forEach(listener => listener());
|
||||
}
|
||||
|
||||
public setInstallationDirectory(newDir: string): Promise<string> {
|
||||
public async setInstallationDirectory(newDir: string): Promise<string> {
|
||||
const oldDir = this.installationDirectory;
|
||||
const newDest = path.join(newDir, this.INSTALLATION_FOLDER);
|
||||
return new Promise<string>(async (resolve, reject) => {
|
||||
await ensureFolderExist(oldDir);
|
||||
|
||||
try {
|
||||
await copyDirectoryWithJunctions(oldDir, newDest, { overwrite: true });
|
||||
await ensureFolderExist(oldDir);
|
||||
|
||||
this._installationDirectory = newDir;
|
||||
this.installPathConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
|
||||
await copyDirectoryWithJunctions(oldDir, newDest, { overwrite: true });
|
||||
|
||||
deleteFolder(oldDir);
|
||||
this._installationDirectory = newDir;
|
||||
this.installPathConfig.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
|
||||
|
||||
return resolve(this.installationDirectory);
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
deleteFolder(oldDir);
|
||||
|
||||
return this.installationDirectory;
|
||||
}
|
||||
|
||||
public onInstallLocationUpdate(fn: Listener) {
|
||||
|
||||
Reference in New Issue
Block a user