Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle galleryExtension failure in featuredExtensionService #184198

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Disposable } from 'vs/base/common/lifecycle';
import { IExtensionGalleryService, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionGalleryService, IExtensionManagementService, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IProductService } from 'vs/platform/product/common/productService';
import { IFeaturedExtension } from 'vs/base/common/product';
Expand Down Expand Up @@ -108,7 +108,12 @@ export class FeaturedExtensionsService extends Disposable implements IFeaturedEx
this.ignoredExtensions.add(extension);
}
else {
const galleryExtension = (await this.galleryService.getExtensions([{ id: extension }], CancellationToken.None))[0];
let galleryExtension: IGalleryExtension | undefined;
try {
galleryExtension = (await this.galleryService.getExtensions([{ id: extension }], CancellationToken.None))[0];
} catch (err) {
continue;
}
if (!await this.extensionManagementService.canInstall(galleryExtension)) {
this.ignoredExtensions.add(extension);
}
Expand Down Expand Up @@ -176,32 +181,40 @@ export class FeaturedExtensionsService extends Disposable implements IFeaturedEx

const storageKey = FeaturedExtensionsService.STORAGE_KEY + '.' + extensionId;
this.storageService.remove(storageKey, StorageScope.APPLICATION);

const galleryExtension = (await this.galleryService.getExtensions([{ id: extensionId }], CancellationToken.None))[0];
let metadata: string | undefined;
if (galleryExtension) {
switch (key) {
case FeaturedExtensionMetadataType.Title: {
metadata = galleryExtension.displayName;
break;
}
case FeaturedExtensionMetadataType.Description: {
metadata = galleryExtension.description;
break;
}
case FeaturedExtensionMetadataType.ImagePath: {
metadata = galleryExtension.assets.icon?.uri;
break;
}
}

this.storageService.store(storageKey, JSON.stringify({
title: galleryExtension.displayName,
description: galleryExtension.description,
imagePath: galleryExtension.assets.icon?.uri,
date: new Date().getTime()
}), StorageScope.APPLICATION, StorageTarget.MACHINE);
let galleryExtension: IGalleryExtension | undefined;
try {
galleryExtension = (await this.galleryService.getExtensions([{ id: extensionId }], CancellationToken.None))[0];
} catch (err) {
}

if (!galleryExtension) {
return metadata;
}

switch (key) {
case FeaturedExtensionMetadataType.Title: {
metadata = galleryExtension.displayName;
break;
}
case FeaturedExtensionMetadataType.Description: {
metadata = galleryExtension.description;
break;
}
case FeaturedExtensionMetadataType.ImagePath: {
metadata = galleryExtension.assets.icon?.uri;
break;
}
}

this.storageService.store(storageKey, JSON.stringify({
title: galleryExtension.displayName,
description: galleryExtension.description,
imagePath: galleryExtension.assets.icon?.uri,
date: new Date().getTime()
}), StorageScope.APPLICATION, StorageTarget.MACHINE);

return metadata;
}
}
Expand Down