Perform partial uninstalls on failed download.

This commit is contained in:
N. Taylor Mullen 2019-05-23 22:24:41 -07:00
Родитель 5818472a75
Коммит 66bdc475ee
1 изменённых файлов: 22 добавлений и 3 удалений

Просмотреть файл

@ -89,10 +89,10 @@ export class DotnetCoreAcquisitionWorker {
if (partialInstall) { if (partialInstall) {
// Partial install, we never updated our extension to no longer be 'installing'. // Partial install, we never updated our extension to no longer be 'installing'.
// uninstall everything and then re-install. // uninstall everything and then re-install.
await this.uninstallAll(); await this.uninstall(version);
} }
const dotnetInstallDir = path.join(this.installDir, version); const dotnetInstallDir = this.getDotnetInstallDir(version);
const dotnetPath = path.join(dotnetInstallDir, this.dotnetExecutable); const dotnetPath = path.join(dotnetInstallDir, this.dotnetExecutable);
if (fs.existsSync(dotnetPath)) { if (fs.existsSync(dotnetPath)) {
@ -121,11 +121,30 @@ export class DotnetCoreAcquisitionWorker {
const versionIndex = latestInstallingVersions.indexOf(version); const versionIndex = latestInstallingVersions.indexOf(version);
if (versionIndex >= 0) { if (versionIndex >= 0) {
latestInstallingVersions.splice(versionIndex, 1); latestInstallingVersions.splice(versionIndex, 1);
await this.extensionState.update(this.installingVersionsKey, latestInstallingVersions);
} }
await this.extensionState.update(this.installingVersionsKey, latestInstallingVersions);
return dotnetPath; return dotnetPath;
} }
private async uninstall(version: string) {
delete this.acquisitionPromises[version];
const dotnetInstallDir = this.getDotnetInstallDir(version);
rimraf.sync(dotnetInstallDir);
const installingVersions = this.extensionState.get<string[]>(this.installingVersionsKey, []);
const versionIndex = installingVersions.indexOf(version);
if (versionIndex >= 0) {
installingVersions.splice(versionIndex, 1);
await this.extensionState.update(this.installingVersionsKey, installingVersions);
}
}
private getDotnetInstallDir(version: string) {
const dotnetInstallDir = path.join(this.installDir, version)
return dotnetInstallDir;
}
private installDotnet(installCommand: string, version: string, dotnetPath: string): Promise<void> { private installDotnet(installCommand: string, version: string, dotnetPath: string): Promise<void> {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {