src/vs/platform/extensionManagement/node/extensionManagementService.ts/ExtensionManagementService/installGalleryExtension
class ExtensionManagementService:	private async installGalleryExtension(gallery: IGalleryExtension, options: InstallOptions, token: CancellationToken): Promise<InstallResult> {
		const startTime = new Date().getTime();
		let operation: InstallOperation = InstallOperation.Install;
		try {
			const installed = await this.getInstalled();
			const existingExtension = installed.find(i => areSameExtensions(i.identifier, gallery.identifier));
			if (existingExtension) {
				operation = InstallOperation.Update;
			}

			const installableExtension = await this.downloadInstallableExtension(gallery, operation);
			installableExtension.metadata.isMachineScoped = options.isMachineScoped || existingExtension?.isMachineScoped;
			installableExtension.metadata.isBuiltin = options.isBuiltin || existingExtension?.isBuiltin;

			const local = await this.installExtension(installableExtension, token);
			if (existingExtension && semver.neq(existingExtension.manifest.version, gallery.version)) {
				await this.extensionsScanner.setUninstalled(existingExtension);
			}
			try { await this.extensionsDownloader.delete(URI.file(installableExtension.zipPath)); } catch (error) { /* Ignore */ }
			this.reportTelemetry(this.getTelemetryEvent(operation), getGalleryExtensionTelemetryData(gallery), new Date().getTime() - startTime, undefined);
			return { local, operation, gallery };
		} catch (error) {
			this.reportTelemetry(this.getTelemetryEvent(operation), getGalleryExtensionTelemetryData(gallery), new Date().getTime() - startTime, error);
			throw error;
		}
	}