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

#155990 add more logging #162837

Merged
merged 1 commit into from Oct 6, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/vs/platform/userDataSync/common/extensionsMerge.ts
Expand Up @@ -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)) {
Expand Down
Expand Up @@ -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 };
})();
}
Expand Down Expand Up @@ -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));
Expand All @@ -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());
Expand All @@ -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));
Expand Down Expand Up @@ -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;
})();
Expand Down Expand Up @@ -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()];
Expand Down
Expand Up @@ -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> {
Expand Down