Skip to content

Commit

Permalink
fix #117169
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Sep 23, 2021
1 parent 07ac6a9 commit e1fb453
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class ExtensionsDownloader extends Disposable {
}

async delete(location: URI): Promise<void> {
// noop as caching is enabled always
await this.cleanUpPromise;
await this.fileService.del(location);
}

private async rename(from: URI, to: URI, retryUntil: number): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,25 @@ class InstallGalleryExtensionTask extends AbstractInstallExtensionTask {
installableExtension.metadata.isMachineScoped = this.options.isMachineScoped || existingExtension?.isMachineScoped;
installableExtension.metadata.isBuiltin = this.options.isBuiltin || existingExtension?.isBuiltin;

const local = await this.installExtension(installableExtension, token);
if (existingExtension && semver.neq(existingExtension.manifest.version, this.gallery.version)) {
await this.extensionsScanner.setUninstalled(existingExtension);
try {
const local = await this.installExtension(installableExtension, token);
if (existingExtension && semver.neq(existingExtension.manifest.version, this.gallery.version)) {
await this.extensionsScanner.setUninstalled(existingExtension);
}
return local;
} catch (error) {
await this.deleteDownloadedVSIX(installableExtension.zipPath);
throw error;
}
}

private async deleteDownloadedVSIX(vsix: string): Promise<void> {
try {
await this.extensionsDownloader.delete(URI.file(vsix));
} catch (error) {
/* Ignore */
this.logService.warn('Error while deleting the downloaded vsix', vsix.toString(), getErrorMessage(error));
}
try { await this.extensionsDownloader.delete(URI.file(installableExtension.zipPath)); } catch (error) { /* Ignore */ }
return local;
}

private async downloadInstallableExtension(extension: IGalleryExtension, operation: InstallOperation): Promise<Required<InstallableExtension>> {
Expand All @@ -316,6 +329,7 @@ class InstallGalleryExtensionTask extends AbstractInstallExtensionTask {
const manifest = await getManifest(zipPath);
return (<Required<InstallableExtension>>{ zipPath, identifierWithVersion: new ExtensionIdentifierWithVersion(extension.identifier, manifest.version), metadata });
} catch (error) {
await this.deleteDownloadedVSIX(zipPath);
throw new ExtensionManagementError(joinErrors(error).message, INSTALL_ERROR_VALIDATING);
}
}
Expand Down

0 comments on commit e1fb453

Please sign in to comment.