Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix #214341

* remove unwanted
  • Loading branch information
sandy081 authored Jun 21, 2024
1 parent e0a7112 commit defc051
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ interface IRawExtensionsControlManifest {
additionalInfo?: string;
}>;
search?: ISearchPrefferedResults[];
extensionsEnabledWithPreRelease?: string[];
}

abstract class AbstractExtensionGalleryService implements IExtensionGalleryService {
Expand Down Expand Up @@ -1310,6 +1311,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
const malicious: IExtensionIdentifier[] = [];
const deprecated: IStringDictionary<IDeprecationInfo> = {};
const search: ISearchPrefferedResults[] = [];
const extensionsEnabledWithPreRelease: string[] = [];
if (result) {
for (const id of result.malicious) {
malicious.push({ id });
Expand Down Expand Up @@ -1341,9 +1343,14 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
search.push(s);
}
}
if (Array.isArray(result.extensionsEnabledWithPreRelease)) {
for (const id of result.extensionsEnabledWithPreRelease) {
extensionsEnabledWithPreRelease.push(id.toLowerCase());
}
}
}

return { malicious, deprecated, search };
return { malicious, deprecated, search, extensionsEnabledWithPreRelease };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ export interface IExtensionsControlManifest {
readonly malicious: IExtensionIdentifier[];
readonly deprecated: IStringDictionary<IDeprecationInfo>;
readonly search: ISearchPrefferedResults[];
readonly extensionsEnabledWithPreRelease?: string[];
}

export const enum InstallOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ export class Extension implements IExtension {
return !!this.gallery?.properties.isPreReleaseVersion;
}

private _extensionEnabledWithPreRelease: boolean | undefined;
get hasPreReleaseVersion(): boolean {
return !!this.gallery?.hasPreReleaseVersion || !!this.local?.hasPreReleaseVersion;
return !!this.gallery?.hasPreReleaseVersion || !!this.local?.hasPreReleaseVersion || !!this._extensionEnabledWithPreRelease;
}

get hasReleaseVersion(): boolean {
Expand Down Expand Up @@ -500,6 +501,12 @@ ${this.description}
return [];
}

setExtensionsControlManifest(extensionsControlManifest: IExtensionsControlManifest): void {
this.isMalicious = extensionsControlManifest.malicious.some(identifier => areSameExtensions(this.identifier, identifier));
this.deprecationInfo = extensionsControlManifest.deprecated ? extensionsControlManifest.deprecated[this.identifier.id.toLowerCase()] : undefined;
this._extensionEnabledWithPreRelease = extensionsControlManifest?.extensionsEnabledWithPreRelease?.includes(this.identifier.id.toLowerCase());
}

private getManifestFromLocalOrResource(): IExtensionManifest | null {
if (this.local) {
return this.local.manifest;
Expand All @@ -515,11 +522,6 @@ const EXTENSIONS_AUTO_UPDATE_KEY = 'extensions.autoUpdate';

class Extensions extends Disposable {

static updateExtensionFromControlManifest(extension: Extension, extensionsControlManifest: IExtensionsControlManifest): void {
extension.isMalicious = extensionsControlManifest.malicious.some(identifier => areSameExtensions(extension.identifier, identifier));
extension.deprecationInfo = extensionsControlManifest.deprecated ? extensionsControlManifest.deprecated[extension.identifier.id.toLowerCase()] : undefined;
}

private readonly _onChange = this._register(new Emitter<{ extension: Extension; operation?: InstallOperation } | undefined>());
get onChange() { return this._onChange.event; }

Expand Down Expand Up @@ -723,7 +725,7 @@ class Extensions extends Disposable {
const extension = byId[local.identifier.id] || this.instantiationService.createInstance(Extension, this.stateProvider, this.runtimeStateProvider, this.server, local, undefined, undefined);
extension.local = local;
extension.enablementState = this.extensionEnablementService.getEnablementState(local);
Extensions.updateExtensionFromControlManifest(extension, extensionsControlManifest);
extension.setExtensionsControlManifest(extensionsControlManifest);
return extension;
});
}
Expand Down Expand Up @@ -759,7 +761,7 @@ class Extensions extends Disposable {
if (!extension.gallery) {
extension.gallery = gallery;
}
Extensions.updateExtensionFromControlManifest(extension, await this.server.extensionManagementService.getExtensionsControlManifest());
extension.setExtensionsControlManifest(await this.server.extensionManagementService.getExtensionsControlManifest());
extension.enablementState = this.extensionEnablementService.getEnablementState(local);
}
}
Expand Down Expand Up @@ -1257,7 +1259,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
let extension = this.getInstalledExtensionMatchingGallery(gallery);
if (!extension) {
extension = this.instantiationService.createInstance(Extension, ext => this.getExtensionState(ext), ext => this.getRuntimeState(ext), undefined, undefined, gallery, undefined);
Extensions.updateExtensionFromControlManifest(<Extension>extension, extensionsControlManifest);
(<Extension>extension).setExtensionsControlManifest(extensionsControlManifest);
}
return extension;
}
Expand Down Expand Up @@ -2010,7 +2012,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
}
if (!extension && gallery) {
extension = this.instantiationService.createInstance(Extension, ext => this.getExtensionState(ext), ext => this.getRuntimeState(ext), undefined, undefined, gallery, undefined);
Extensions.updateExtensionFromControlManifest(extension as Extension, await this.extensionManagementService.getExtensionsControlManifest());
(<Extension>extension).setExtensionsControlManifest(await this.extensionManagementService.getExtensionsControlManifest());
}
if (extension?.isMalicious) {
throw new Error(nls.localize('malicious', "This extension is reported to be problematic."));
Expand Down

0 comments on commit defc051

Please sign in to comment.