#155990 add more logging (#162837)

This commit is contained in:
Sandeep Somavarapu 2022-10-06 16:21:27 +02:00 committed by GitHub
parent 19f4680c26
commit e42366e69e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 29 deletions

View file

@ -179,7 +179,7 @@ export function merge(localExtensions: ISyncExtensionWithVersion[], remoteExtens
newRemoteExtensionsMap.set(key, merge(key, localExtension, remoteExtension, localExtension));
}
// Locally removed extensions => exist in base and does not exit in local
// Locally removed extensions => exist in base and does not exist in local
for (const key of baseToLocal.removed.values()) {
// If updated in remote (already handled)
if (baseToRemote.updated.has(key)) {

View file

@ -137,6 +137,12 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
if (extensions.length) {
extensions = await this.checkAdditionalBuiltinExtensions(extensions);
}
if (extensions.length) {
this.logService.info('Found additional builtin gallery extensions in env', extensions);
}
if (extensionLocations.length) {
this.logService.info('Found additional builtin location extensions in env', extensionLocations.map(e => e.toString()));
}
return { extensions, extensionsToMigrate, extensionLocations };
})();
}
@ -209,6 +215,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
const extension = await this.toScannedExtension(webExtension, true);
if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
result.push(extension);
} else {
this.logService.info(`Skipping invalid additional builtin extension ${webExtension.identifier.id}`);
}
} catch (error) {
this.logService.info(`Error while fetching the additional builtin extension ${location.toString()}.`, getErrorMessage(error));
@ -218,15 +226,12 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
}
private async getCustomBuiltinExtensionsFromGallery(scanOptions?: ScanOptions): Promise<IScannedExtension[]> {
const { extensions } = await this.readCustomBuiltinExtensionsInfoFromEnv();
if (!extensions.length) {
return [];
}
if (!this.galleryService.isEnabled()) {
this.logService.info('Ignoring fetching additional builtin extensions from gallery as it is disabled.');
return [];
}
const result: IScannedExtension[] = [];
const { extensions } = await this.readCustomBuiltinExtensionsInfoFromEnv();
try {
const useCache = this.storageService.get('additionalBuiltinExtensions', StorageScope.APPLICATION, '[]') === JSON.stringify(extensions);
const webExtensions = await (useCache ? this.getCustomBuiltinExtensionsFromCache() : this.updateCustomBuiltinExtensionsCache());
@ -236,6 +241,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
const extension = await this.toScannedExtension(webExtension, true);
if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
result.push(extension);
} else {
this.logService.info(`Skipping invalid additional builtin gallery extension ${webExtension.identifier.id}`);
}
} catch (error) {
this.logService.info(`Ignoring additional builtin extension ${webExtension.identifier.id} because there is an error while converting it into scanned extension`, getErrorMessage(error));
@ -318,31 +325,23 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
private async updateCustomBuiltinExtensionsCache(): Promise<IWebExtension[]> {
if (!this._updateCustomBuiltinExtensionsCachePromise) {
this._updateCustomBuiltinExtensionsCachePromise = (async () => {
// Clear Cache
await this.writeCustomBuiltinExtensionsCache(() => []);
const { extensions } = await this.readCustomBuiltinExtensionsInfoFromEnv();
if (!extensions.length) {
return [];
}
const galleryExtensionsMap = await this.getExtensionsWithDependenciesAndPackedExtensions(extensions);
const missingExtensions = extensions.filter(({ id }) => !galleryExtensionsMap.has(id.toLowerCase()));
if (missingExtensions.length) {
this.logService.info('Skipping the additional builtin extensions because their compatible versions are not found.', missingExtensions);
}
this.logService.info('Updating additional builtin extensions cache');
const webExtensions: IWebExtension[] = [];
await Promise.all([...galleryExtensionsMap.values()].map(async gallery => {
try {
webExtensions.push(await this.toWebExtensionFromGallery(gallery, { isPreReleaseVersion: gallery.properties.isPreReleaseVersion, preRelease: gallery.properties.isPreReleaseVersion, isBuiltin: true }));
} catch (error) {
this.logService.info(`Ignoring additional builtin extension ${gallery.identifier.id} because there is an error while converting it into web extension`, getErrorMessage(error));
const { extensions } = await this.readCustomBuiltinExtensionsInfoFromEnv();
if (extensions.length) {
const galleryExtensionsMap = await this.getExtensionsWithDependenciesAndPackedExtensions(extensions);
const missingExtensions = extensions.filter(({ id }) => !galleryExtensionsMap.has(id.toLowerCase()));
if (missingExtensions.length) {
this.logService.info('Skipping the additional builtin extensions because their compatible versions are not found.', missingExtensions);
}
}));
await Promise.all([...galleryExtensionsMap.values()].map(async gallery => {
try {
webExtensions.push(await this.toWebExtensionFromGallery(gallery, { isPreReleaseVersion: gallery.properties.isPreReleaseVersion, preRelease: gallery.properties.isPreReleaseVersion, isBuiltin: true }));
} catch (error) {
this.logService.info(`Ignoring additional builtin extension ${gallery.identifier.id} because there is an error while converting it into web extension`, getErrorMessage(error));
}
}));
}
await this.writeCustomBuiltinExtensionsCache(() => webExtensions);
return webExtensions;
})();
@ -534,6 +533,8 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
const extension = await this.toScannedExtension(webExtension, false);
if (extension.isValid || !scanOptions?.skipInvalidExtensions) {
result.set(extension.identifier.id.toLowerCase(), extension);
} else {
this.logService.info(`Skipping invalid installed extension ${webExtension.identifier.id}`);
}
}
return [...result.values()];

View file

@ -93,7 +93,7 @@ export class WebExtensionManagementService extends AbstractExtensionManagementSe
const userExtensions = await this.webExtensionsScannerService.scanUserExtensions(profileLocation ?? this.userDataProfileService.currentProfile.extensionsResource);
extensions.push(...userExtensions);
}
return Promise.all(extensions.map(e => toLocalExtension(e)));
return extensions.map(e => toLocalExtension(e));
}
async install(location: URI, options: InstallOptions = {}): Promise<ILocalExtension> {