Skip to content

Commit 0519295

Browse files
committed
1 parent e53bee0 commit 0519295

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ export interface IGalleryMetadata {
268268
id: string;
269269
publisherId: string;
270270
publisherDisplayName: string;
271+
isPreReleaseVersion: boolean,
271272
}
272273

274+
export type Metadata = Partial<IGalleryMetadata & { isMachineScoped: boolean; isBuiltin: boolean; preRelease: boolean, installedTimestamp: number }>;
275+
273276
export interface ILocalExtension extends IExtension {
274277
isMachineScoped: boolean;
275278
publisherId: string | null;
@@ -389,7 +392,6 @@ export class ExtensionManagementError extends Error {
389392
}
390393
}
391394

392-
export type Metadata = Partial<IGalleryMetadata & { isMachineScoped: boolean; isBuiltin: boolean; isPreReleaseVersion: boolean, preRelease: boolean, installedTimestamp: number }>;
393395
export type InstallOptions = { isBuiltin?: boolean, isMachineScoped?: boolean, donotIncludePackAndDependencies?: boolean, installGivenVersion?: boolean, installPreReleaseVersion?: boolean };
394396
export type InstallVSIXOptions = Omit<InstallOptions, 'installGivenVersion'> & { installOnlyNewlyAddedFromExtensionPack?: boolean };
395397
export type UninstallOptions = { donotIncludePack?: boolean, donotCheckDependents?: boolean };

src/vs/platform/extensionManagement/node/extensionManagementService.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
148148

149149
async updateMetadata(local: ILocalExtension, metadata: IGalleryMetadata): Promise<ILocalExtension> {
150150
this.logService.trace('ExtensionManagementService#updateMetadata', local.identifier.id);
151-
local = await this.extensionsScanner.saveMetadataForLocalExtension(local, { ...((<ILocalExtensionManifest>local.manifest).__metadata || {}), ...metadata });
151+
const localMetadata: Metadata = { ...((<ILocalExtensionManifest>local.manifest).__metadata || {}), ...metadata };
152+
if (metadata.isPreReleaseVersion) {
153+
localMetadata.preRelease = true;
154+
}
155+
local = await this.extensionsScanner.saveMetadataForLocalExtension(local, localMetadata);
152156
this.manifestCache.invalidate();
153157
return local;
154158
}
@@ -354,7 +358,7 @@ class InstallVSIXTask extends AbstractInstallExtensionTask {
354358
const identifierWithVersion = new ExtensionIdentifierWithVersion(this.identifier, this.manifest.version);
355359
const installedExtensions = await this.extensionsScanner.scanExtensions(ExtensionType.User);
356360
const existing = installedExtensions.find(i => areSameExtensions(this.identifier, i.identifier));
357-
const metadata = await this.getMetadata(this.identifier.id, token);
361+
const metadata = await this.getMetadata(this.identifier.id, this.manifest.version, token);
358362
metadata.isMachineScoped = this.options.isMachineScoped || existing?.isMachineScoped;
359363
metadata.isBuiltin = this.options.isBuiltin || existing?.isBuiltin;
360364

@@ -385,11 +389,14 @@ class InstallVSIXTask extends AbstractInstallExtensionTask {
385389
return this.installExtension({ zipPath: path.resolve(this.location.fsPath), identifierWithVersion, metadata }, token);
386390
}
387391

388-
private async getMetadata(name: string, token: CancellationToken): Promise<Metadata> {
392+
private async getMetadata(id: string, version: string, token: CancellationToken): Promise<Metadata> {
389393
try {
390-
const galleryExtension = (await this.galleryService.query({ names: [name], pageSize: 1 }, token)).firstPage[0];
394+
let [galleryExtension] = await this.galleryService.getExtensions([{ id, version }], token);
395+
if (!galleryExtension) {
396+
[galleryExtension] = await this.galleryService.getExtensions([{ id }], token);
397+
}
391398
if (galleryExtension) {
392-
return { id: galleryExtension.identifier.uuid, publisherDisplayName: galleryExtension.publisherDisplayName, publisherId: galleryExtension.publisherId };
399+
return { id: galleryExtension.identifier.uuid, publisherDisplayName: galleryExtension.publisherDisplayName, publisherId: galleryExtension.publisherId, isPreReleaseVersion: galleryExtension.properties.isPreReleaseVersion, preRelease: galleryExtension.properties.isPreReleaseVersion };
393400
}
394401
} catch (error) {
395402
/* Ignore Error */

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,26 @@ class Extensions extends Disposable {
437437
hasChanged = true;
438438
}
439439

440-
const compatible = await this.getCompatibleExtension(gallery, !!extension.local?.isPreReleaseVersion);
440+
const compatible = await this.getCompatibleExtension(gallery, extension.local.isPreReleaseVersion);
441441
if (compatible) {
442-
const local = extension.local.identifier.uuid ? extension.local : await this.server.extensionManagementService.updateMetadata(extension.local, { id: compatible.identifier.uuid, publisherDisplayName: compatible.publisherDisplayName, publisherId: compatible.publisherId });
443-
extension.local = local;
444442
extension.gallery = compatible;
445443
hasChanged = true;
446444
}
447445

446+
if (!extension.local.identifier.uuid) {
447+
let galleryExtension = !extension.outdated ? extension.gallery : undefined;
448+
if (!galleryExtension) {
449+
[galleryExtension] = await this.galleryService.getExtensions([{ ...extension.local.identifier, version: extension.version }], CancellationToken.None);
450+
}
451+
if (!galleryExtension) {
452+
[galleryExtension] = await this.galleryService.getExtensions([extension.local.identifier], CancellationToken.None);
453+
}
454+
if (galleryExtension) {
455+
const local = await this.server.extensionManagementService.updateMetadata(extension.local, { id: galleryExtension.identifier.uuid, publisherDisplayName: galleryExtension.publisherDisplayName, publisherId: galleryExtension.publisherId, isPreReleaseVersion: gallery.properties.isPreReleaseVersion });
456+
extension.local = local;
457+
}
458+
}
459+
448460
const unsupportedPreRelease = extensionsControlManifest.unsupportedPreReleaseExtensions ? extensionsControlManifest.unsupportedPreReleaseExtensions[extension.identifier.id.toLowerCase()] : undefined;
449461
if (unsupportedPreRelease) {
450462
if (isBoolean(extension.isUnsupported) || !areSameExtensions({ id: extension.isUnsupported.preReleaseExtension.id }, { id: unsupportedPreRelease.id })) {

0 commit comments

Comments
 (0)