Skip to content

Commit

Permalink
dont run cache and gallery queries in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Mar 16, 2016
1 parent f01eaa6 commit 0d7250e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/vs/workbench/parts/extensions/common/vsoGalleryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,27 @@ export class GalleryService implements IGalleryService {
return TPromise.wrapError(new Error('No extension gallery service configured.'));
}

const gallery = this.queryGallery();
const cache = this.queryCache().then(r => {
const rawLastModified = r.getResponseHeader('last-modified');
const raw = this.queryCache()
.then(null, err => this.queryGallery())
.then(result => {
const rawLastModified = result.getResponseHeader('last-modified');

if (!rawLastModified) {
return gallery;
}
if (!rawLastModified) {
return this.queryGallery();
}

const lastModified = new Date(rawLastModified).getTime();
const now = new Date().getTime();
const diff = now - lastModified;
const lastModified = new Date(rawLastModified).getTime();
const now = new Date().getTime();
const diff = now - lastModified;

if (diff > FIVE_MINUTES) {
return gallery;
}
if (diff > FIVE_MINUTES) {
return this.queryGallery();
}

gallery.cancel();
return TPromise.as(r);
}, err => gallery);
return TPromise.as(result);
});

return cache
return raw
.then<IGalleryExtension[]>(r => JSON.parse(r.responseText).results[0].extensions || [])
.then<IExtension[]>(extensions => {
return extensions.map(e => {
Expand Down

0 comments on commit 0d7250e

Please sign in to comment.