diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index 2fde7589e29..da7be6d1d7a 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -112,7 +112,6 @@ export interface IWindowConfiguration extends ICommandLineArguments { crashReporter: Electron.CrashReporterStartOptions; extensionsGallery: { serviceUrl: string; - cacheUrl: string; itemUrl: string; }; extensionTips: { [id: string]: string; }; diff --git a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts index d40e66ebe20..6899a36a931 100644 --- a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts @@ -6,12 +6,9 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IExtension, IExtensionGalleryService, IGalleryVersion, IQueryOptions, IQueryResult } from 'vs/platform/extensionManagement/common/extensionManagement'; import { isUndefined } from 'vs/base/common/types'; -import { IXHRResponse } from 'vs/base/common/http'; import { assign, getOrDefault } from 'vs/base/common/objects'; import { IRequestService } from 'vs/platform/request/common/request'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { matchesContiguousSubString } from 'vs/base/common/filters'; -import { getExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil'; import pkg from 'vs/platform/package'; import product from 'vs/platform/product'; @@ -191,23 +188,11 @@ function toExtension(galleryExtension: IGalleryExtension, extensionsGalleryUrl: }; } -const FIVE_MINUTES = 1000 * 60 * 5; - -function extensionFilter(input: string): (e: IExtension) => boolean { - return extension => { - return !!matchesContiguousSubString(input, `${ extension.publisher }.${ extension.name }`) - || !!matchesContiguousSubString(input, extension.name) - || !!matchesContiguousSubString(input, extension.displayName) - || !!matchesContiguousSubString(input, extension.description); - }; -} - export class ExtensionGalleryService implements IExtensionGalleryService { serviceId = IExtensionGalleryService; private extensionsGalleryUrl: string; - private extensionsCacheUrl: string; private machineId: TPromise; constructor( @@ -216,7 +201,6 @@ export class ExtensionGalleryService implements IExtensionGalleryService { ) { const config = product.extensionsGallery; this.extensionsGalleryUrl = config && config.serviceUrl; - this.extensionsCacheUrl = config && config.cacheUrl; this.machineId = telemetryService.getTelemetryInfo().then(({ machineId }) => machineId); } @@ -235,53 +219,10 @@ export class ExtensionGalleryService implements IExtensionGalleryService { const type = options.ids ? 'ids' : (options.text ? 'text' : 'all'); const text = options.text || ''; + const pageSize = getOrDefault(options, o => o.pageSize, 30); + this.telemetryService.publicLog('galleryService:query', { type, text }); - const cache = this.queryCache().then(result => { - const rawLastModified = result.getResponseHeader('last-modified'); - - if (!rawLastModified) { - return TPromise.wrapError('no last modified header'); - } - - const lastModified = new Date(rawLastModified).getTime(); - const now = new Date().getTime(); - const diff = now - lastModified; - - if (diff > FIVE_MINUTES) { - return TPromise.wrapError('stale'); - } - - return this.getRequestHeaders().then(downloadHeaders => { - const rawExtensions: IGalleryExtension[] = JSON.parse(result.responseText).results[0].extensions || []; - let extensions = rawExtensions - .map(e => toExtension(e, this.extensionsGalleryUrl, downloadHeaders)); - - if (options.ids) { - extensions = extensions.filter(e => options.ids.indexOf(getExtensionId(e)) > -1); - } else if (options.text) { - extensions = extensions.filter(extensionFilter(options.text)); - } - - extensions = extensions - .sort((a, b) => b.galleryInformation.installCount - a.galleryInformation.installCount); - - return { - firstPage: extensions, - total: extensions.length, - pageSize: extensions.length, - getPage: () => TPromise.as([]) - }; - }); - }); - - return cache.then(null, _ => this._query(options)); - } - - private _query(options: IQueryOptions = {}): TPromise { - const text = getOrDefault(options, o => o.text, ''); - const pageSize = getOrDefault(options, o => o.pageSize, 50); - let query = new Query() .withFlags(Flags.IncludeVersions, Flags.IncludeCategoryAndTags, Flags.IncludeAssetUri, Flags.IncludeStatistics) .withPage(1, pageSize) @@ -338,16 +279,6 @@ export class ExtensionGalleryService implements IExtensionGalleryService { }); } - private queryCache(): TPromise { - const url = this.extensionsCacheUrl; - - if (!url) { - return TPromise.wrapError(new Error('No cache configured.')); - } - - return this.requestService.makeRequest({ url }); - } - private getRequestHeaders(): TPromise { return this.machineId.then(machineId => { const result = { diff --git a/src/vs/platform/product.ts b/src/vs/platform/product.ts index 385a0d7a5f9..deb201dd345 100644 --- a/src/vs/platform/product.ts +++ b/src/vs/platform/product.ts @@ -21,7 +21,6 @@ export interface IProductConfiguration { date: string; extensionsGallery: { serviceUrl: string; - cacheUrl: string; itemUrl: string; }; extensionTips: { [id: string]: string; }; diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 8d4dc3617df..281f5ca4cd5 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -101,7 +101,6 @@ export interface IEnvironment { extensionsGallery: { serviceUrl: string; - cacheUrl: string; itemUrl: string; };