src/vs/platform/extensionManagement/node/extensionManagementService.ts/InstallGalleryExtensionTask/doRun
class InstallGalleryExtensionTask:	protected async doRun(token: CancellationToken): Promise<ILocalExtension> {
		const installed = await this.extensionsScanner.scanExtensions(null);
		const existingExtension = installed.find(i => areSameExtensions(i.identifier, this.gallery.identifier));
		if (existingExtension) {
			this._operation = InstallOperation.Update;
		}

		const installableExtension = await this.downloadInstallableExtension(this.gallery, this._operation);
		installableExtension.metadata.isMachineScoped = this.options.isMachineScoped || existingExtension?.isMachineScoped;
		installableExtension.metadata.isBuiltin = this.options.isBuiltin || existingExtension?.isBuiltin;
		installableExtension.metadata.isSystem = existingExtension?.type === ExtensionType.System ? true : undefined;
		installableExtension.metadata.updated = !!existingExtension;
		installableExtension.metadata.isPreReleaseVersion = this.gallery.properties.isPreReleaseVersion;
		installableExtension.metadata.preRelease = this.gallery.properties.isPreReleaseVersion ||
			(isBoolean(this.options.installPreReleaseVersion)
				? this.options.installPreReleaseVersion /* Respect the passed flag */
				: existingExtension?.preRelease /* Respect the existing pre-release flag if it was set */);

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