check pre-release flag on local extension while syncing - to avoid multiple queries to get compatible extension

This commit is contained in:
Sandeep Somavarapu 2021-12-10 14:09:03 +01:00
parent 05de5834b0
commit 7334561f2b
No known key found for this signature in database
GPG key ID: 1FED25EC4646638B

View file

@ -1005,27 +1005,41 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
.then(undefined, err => null);
}
private syncWithGallery(): Promise<void> {
const ids: string[] = [], names: string[] = [];
private async syncWithGallery(): Promise<void> {
const ids: string[] = [], preReleaseIds: string[] = [], names: string[] = [], preReleaseNames: string[] = [];
for (const installed of this.local) {
if (installed.type === ExtensionType.User) {
if (installed.identifier.uuid) {
ids.push(installed.identifier.uuid);
if (installed.local?.isPreReleaseVersion || installed.local?.preRelease) {
preReleaseIds.push(installed.identifier.uuid);
} else {
ids.push(installed.identifier.uuid);
}
} else {
names.push(installed.identifier.id);
if (installed.local?.isPreReleaseVersion || installed.local?.preRelease) {
preReleaseNames.push(installed.identifier.id);
} else {
names.push(installed.identifier.id);
}
}
}
}
const promises: Promise<IPager<IExtension>>[] = [];
if (ids.length) {
promises.push(this.queryGallery({ ids, pageSize: ids.length }, CancellationToken.None));
promises.push(this.queryGallery({ ids, pageSize: ids.length, includePreRelease: false }, CancellationToken.None));
}
if (preReleaseIds.length) {
promises.push(this.queryGallery({ ids: preReleaseIds, pageSize: preReleaseIds.length, includePreRelease: true }, CancellationToken.None));
}
if (names.length) {
promises.push(this.queryGallery({ names, pageSize: names.length }, CancellationToken.None));
promises.push(this.queryGallery({ names, pageSize: names.length, includePreRelease: false }, CancellationToken.None));
}
if (preReleaseNames.length) {
promises.push(this.queryGallery({ names: preReleaseNames, pageSize: names.length, includePreRelease: true }, CancellationToken.None));
}
return Promises.settled(promises).then(() => undefined);
await Promises.settled(promises);
}
private eventuallyAutoUpdateExtensions(): void {