Skip to content

Commit 86bb523

Browse files
authored
1 parent 0dd3429 commit 86bb523

File tree

6 files changed

+26
-51
lines changed

6 files changed

+26
-51
lines changed

src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
118118

119119
await Promise.allSettled(extensions.map(async ({ extension, options }) => {
120120
try {
121-
const compatible = await this.checkAndGetCompatibleVersion(extension, !!options?.installGivenVersion, !!options?.installPreReleaseVersion, false);
121+
const compatible = await this.checkAndGetCompatibleVersion(extension, !!options?.installGivenVersion, !!options?.installPreReleaseVersion);
122122
installableExtensions.push({ ...compatible, options });
123123
} catch (error) {
124124
results.push({ identifier: extension.identifier, operation: InstallOperation.Install, source: extension, error });
@@ -434,7 +434,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
434434
const isDependency = dependecies.some(id => areSameExtensions({ id }, galleryExtension.identifier));
435435
let compatible;
436436
try {
437-
compatible = await this.checkAndGetCompatibleVersion(galleryExtension, false, installPreRelease, true);
437+
compatible = await this.checkAndGetCompatibleVersion(galleryExtension, false, installPreRelease);
438438
} catch (error) {
439439
if (!isDependency) {
440440
this.logService.info('Skipping the packed extension as it cannot be installed', galleryExtension.identifier.id, getErrorMessage(error));
@@ -454,7 +454,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
454454
return allDependenciesAndPacks;
455455
}
456456

457-
private async checkAndGetCompatibleVersion(extension: IGalleryExtension, sameVersion: boolean, installPreRelease: boolean, fallbackToRelease: boolean): Promise<{ extension: IGalleryExtension; manifest: IExtensionManifest }> {
457+
private async checkAndGetCompatibleVersion(extension: IGalleryExtension, sameVersion: boolean, installPreRelease: boolean): Promise<{ extension: IGalleryExtension; manifest: IExtensionManifest }> {
458458
const extensionsControlManifest = await this.getExtensionsControlManifest();
459459
if (extensionsControlManifest.malicious.some(identifier => areSameExtensions(extension.identifier, identifier))) {
460460
throw new ExtensionManagementError(nls.localize('malicious extension', "Can't install '{0}' extension since it was reported to be problematic.", extension.identifier.id), ExtensionManagementErrorCode.Malicious);
@@ -466,11 +466,7 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
466466
}
467467

468468
const compatibleExtension = await this.getCompatibleVersion(extension, sameVersion, installPreRelease);
469-
if (compatibleExtension) {
470-
if (!fallbackToRelease && installPreRelease && !sameVersion && extension.hasPreReleaseVersion && !compatibleExtension.properties.isPreReleaseVersion) {
471-
throw new ExtensionManagementError(nls.localize('notFoundCompatiblePrereleaseDependency', "Can't install pre-release version of '{0}' extension because it is not compatible with the current version of {1} (version {2}).", extension.identifier.id, this.productService.nameLong, this.productService.version), ExtensionManagementErrorCode.IncompatiblePreRelease);
472-
}
473-
} else {
469+
if (!compatibleExtension) {
474470
/** If no compatible release version is found, check if the extension has a release version or not and throw relevant error */
475471
if (!installPreRelease && extension.properties.isPreReleaseVersion && (await this.galleryService.getExtensions([extension.identifier], CancellationToken.None))[0]) {
476472
throw new ExtensionManagementError(nls.localize('notFoundReleaseExtension', "Can't install release version of '{0}' extension because it has no release version.", extension.identifier.id), ExtensionManagementErrorCode.ReleaseVersionNotFound);

src/vs/platform/extensionManagement/common/extensionManagement.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ export enum ExtensionManagementErrorCode {
407407
Deprecated = 'Deprecated',
408408
Malicious = 'Malicious',
409409
Incompatible = 'Incompatible',
410-
IncompatiblePreRelease = 'IncompatiblePreRelease',
411410
IncompatibleTargetPlatform = 'IncompatibleTargetPlatform',
412411
ReleaseVersionNotFound = 'ReleaseVersionNotFound',
413412
Invalid = 'Invalid',

src/vs/platform/userDataSync/common/extensionsSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ export class LocalExtensionsProvider {
527527
addToSkipped.push(e);
528528
this.logService.info(`${syncResourceLogLabel}: Skipped synchronizing extension`, gallery.displayName || gallery.identifier.id);
529529
}
530-
if (error instanceof ExtensionManagementError && [ExtensionManagementErrorCode.Incompatible, ExtensionManagementErrorCode.IncompatiblePreRelease, ExtensionManagementErrorCode.IncompatibleTargetPlatform].includes(error.code)) {
530+
if (error instanceof ExtensionManagementError && [ExtensionManagementErrorCode.Incompatible, ExtensionManagementErrorCode.IncompatibleTargetPlatform].includes(error.code)) {
531531
this.logService.info(`${syncResourceLogLabel}: Skipped synchronizing extension because the compatible extension is not found.`, gallery.displayName || gallery.identifier.id);
532532
} else if (error) {
533533
this.logService.error(error);

src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
678678
try {
679679
await this.extensionsWorkbenchService.install(extension, extension.local?.preRelease ? { installPreReleaseVersion: true } : undefined);
680680
} catch (err) {
681-
runAction(this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Update, undefined, err));
681+
runAction(this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Update, err));
682682
}
683683
}));
684684
}

src/vs/workbench/contrib/extensions/browser/extensionsActions.ts

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export class PromptExtensionInstallFailureAction extends Action {
7878
private readonly extension: IExtension,
7979
private readonly version: string,
8080
private readonly installOperation: InstallOperation,
81-
private readonly installOptions: InstallOptions | undefined,
8281
private readonly error: Error,
8382
@IProductService private readonly productService: IProductService,
8483
@IOpenerService private readonly openerService: IOpenerService,
@@ -138,44 +137,29 @@ export class PromptExtensionInstallFailureAction extends Action {
138137
return;
139138
}
140139

141-
let operationMessage = this.installOperation === InstallOperation.Update ? localize('update operation', "Error while updating '{0}' extension.", this.extension.displayName || this.extension.identifier.id)
140+
const operationMessage = this.installOperation === InstallOperation.Update ? localize('update operation', "Error while updating '{0}' extension.", this.extension.displayName || this.extension.identifier.id)
142141
: localize('install operation', "Error while installing '{0}' extension.", this.extension.displayName || this.extension.identifier.id);
143142
let additionalMessage;
144143
const promptChoices: IPromptChoice[] = [];
145144

146-
if (ExtensionManagementErrorCode.IncompatiblePreRelease === (<ExtensionManagementErrorCode>this.error.name)) {
147-
operationMessage = getErrorMessage(this.error);
148-
additionalMessage = localize('install release version message', "Would you like to install the release version?");
145+
const downloadUrl = await this.getDownloadUrl();
146+
if (downloadUrl) {
147+
additionalMessage = localize('check logs', "Please check the [log]({0}) for more details.", `command:${showWindowLogActionId}`);
149148
promptChoices.push({
150-
label: localize('install release version', "Install Release Version"),
151-
run: () => {
152-
const installAction = this.instantiationService.createInstance(InstallAction, { installPreReleaseVersion: !!this.installOptions?.installPreReleaseVersion });
153-
installAction.extension = this.extension;
154-
return installAction.run();
155-
}
149+
label: localize('download', "Try Downloading Manually..."),
150+
run: () => this.openerService.open(downloadUrl).then(() => {
151+
this.notificationService.prompt(
152+
Severity.Info,
153+
localize('install vsix', 'Once downloaded, please manually install the downloaded VSIX of \'{0}\'.', this.extension.identifier.id),
154+
[{
155+
label: localize('installVSIX', "Install from VSIX..."),
156+
run: () => this.commandService.executeCommand(SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID)
157+
}]
158+
);
159+
})
156160
});
157161
}
158162

159-
else {
160-
const downloadUrl = await this.getDownloadUrl();
161-
if (downloadUrl) {
162-
additionalMessage = localize('check logs', "Please check the [log]({0}) for more details.", `command:${showWindowLogActionId}`);
163-
promptChoices.push({
164-
label: localize('download', "Try Downloading Manually..."),
165-
run: () => this.openerService.open(downloadUrl).then(() => {
166-
this.notificationService.prompt(
167-
Severity.Info,
168-
localize('install vsix', 'Once downloaded, please manually install the downloaded VSIX of \'{0}\'.', this.extension.identifier.id),
169-
[{
170-
label: localize('installVSIX', "Install from VSIX..."),
171-
run: () => this.commandService.executeCommand(SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID)
172-
}]
173-
);
174-
})
175-
});
176-
}
177-
}
178-
179163
const message = `${operationMessage}${additionalMessage ? ` ${additionalMessage}` : ''}`;
180164
this.notificationService.prompt(Severity.Error, message, promptChoices);
181165
}
@@ -469,7 +453,7 @@ export class InstallAction extends ExtensionAction {
469453
try {
470454
return await this.extensionsWorkbenchService.install(extension, this.options);
471455
} catch (error) {
472-
await this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, this.options, error).run();
456+
await this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, error).run();
473457
return undefined;
474458
}
475459
}
@@ -837,7 +821,7 @@ export class UpdateAction extends AbstractUpdateAction {
837821
await this.extensionsWorkbenchService.install(extension, extension.local?.preRelease ? { installPreReleaseVersion: true } : undefined);
838822
alert(localize('updateExtensionComplete', "Updating extension {0} to version {1} completed.", extension.displayName, extension.latestVersion));
839823
} catch (err) {
840-
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Update, undefined, err).run();
824+
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Update, err).run();
841825
}
842826
}
843827
}
@@ -1304,7 +1288,7 @@ export class InstallAnotherVersionAction extends ExtensionAction {
13041288
await this.extensionsWorkbenchService.installVersion(this.extension!, pick.id, { installPreReleaseVersion: pick.isPreReleaseVersion });
13051289
}
13061290
} catch (error) {
1307-
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, this.extension!, pick.latest ? this.extension!.latestVersion : pick.id, InstallOperation.Install, undefined, error).run();
1291+
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, this.extension!, pick.latest ? this.extension!.latestVersion : pick.id, InstallOperation.Install, error).run();
13081292
}
13091293
}
13101294
return null;
@@ -1811,7 +1795,7 @@ export class InstallRecommendedExtensionAction extends Action {
18111795
try {
18121796
await this.extensionWorkbenchService.install(extension);
18131797
} catch (err) {
1814-
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, undefined, err).run();
1798+
this.instantiationService.createInstance(PromptExtensionInstallFailureAction, extension, extension.latestVersion, InstallOperation.Install, err).run();
18151799
}
18161800
}
18171801
}

src/vs/workbench/services/extensionManagement/electron-sandbox/remoteExtensionManagementService.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ export class NativeRemoteExtensionManagementService extends RemoteExtensionManag
129129
compatibleExtension = await this.galleryService.getCompatibleExtension(extension, includePreRelease, targetPlatform);
130130
}
131131

132-
if (compatibleExtension) {
133-
if (includePreRelease && !compatibleExtension.properties.isPreReleaseVersion && extension.hasPreReleaseVersion) {
134-
throw new ExtensionManagementError(localize('notFoundCompatiblePrereleaseDependency', "Can't install pre-release version of '{0}' extension because it is not compatible with the current version of {1} (version {2}).", extension.identifier.id, this.productService.nameLong, this.productService.version), ExtensionManagementErrorCode.IncompatiblePreRelease);
135-
}
136-
} else {
132+
if (!compatibleExtension) {
137133
/** If no compatible release version is found, check if the extension has a release version or not and throw relevant error */
138134
if (!includePreRelease && extension.properties.isPreReleaseVersion && (await this.galleryService.getExtensions([extension.identifier], CancellationToken.None))[0]) {
139135
throw new ExtensionManagementError(localize('notFoundReleaseExtension', "Can't install release version of '{0}' extension because it has no release version.", extension.identifier.id), ExtensionManagementErrorCode.ReleaseVersionNotFound);

0 commit comments

Comments
 (0)