From 89ca6300517de1a8dbd257085eacad2fbc1fd012 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Fri, 23 Feb 2018 16:44:58 -0800 Subject: [PATCH] Resolve file before resolving content Fixes #44092 --- .../electron-browser/extensionTipsService.ts | 7 +++-- .../parts/stats/node/workspaceStats.ts | 30 +++++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts index 433f5c68fe0..e8f205a4bd8 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts @@ -265,8 +265,11 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe } private resolveWorkspaceFolderRecommendations(workspaceFolder: IWorkspaceFolder): TPromise { - return this.fileService.resolveContent(workspaceFolder.toResource(paths.join('.vscode', 'extensions.json'))) - .then(content => this.processWorkspaceRecommendations(json.parse(content.value, [])), err => []); + const extensionsJsonUri = workspaceFolder.toResource(paths.join('.vscode', 'extensions.json')); + return this.fileService.resolveFile(extensionsJsonUri).then(() => { + return this.fileService.resolveContent(extensionsJsonUri) + .then(content => this.processWorkspaceRecommendations(json.parse(content.value, [])), err => []); + }, err => []); } private processWorkspaceRecommendations(extensionsContent: IExtensionsContent): TPromise { diff --git a/src/vs/workbench/parts/stats/node/workspaceStats.ts b/src/vs/workbench/parts/stats/node/workspaceStats.ts index 02d88e1cdc5..6e6398e5a13 100644 --- a/src/vs/workbench/parts/stats/node/workspaceStats.ts +++ b/src/vs/workbench/parts/stats/node/workspaceStats.ts @@ -139,10 +139,12 @@ export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: bool export function getHashedRemotesFromUri(workspaceUri: URI, fileService: IFileService, stripEndingDotGit: boolean = false): TPromise { let path = workspaceUri.path; let uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` }); - return fileService.resolveContent(uri, { acceptTextOnly: true }).then( - content => getHashedRemotesFromConfig(content.value, stripEndingDotGit), - err => [] // ignore missing or binary file - ); + return fileService.resolveFile(uri).then(() => { + return fileService.resolveContent(uri, { acceptTextOnly: true }).then( + content => getHashedRemotesFromConfig(content.value, stripEndingDotGit), + err => [] // ignore missing or binary file + ); + }, err => []); } export class WorkspaceStats implements IWorkbenchContribution { @@ -323,10 +325,12 @@ export class WorkspaceStats implements IWorkbenchContribution { TPromise.join(workspaceUris.map(workspaceUri => { const path = workspaceUri.path; const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` }); - return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( - content => getDomainsOfRemotes(content.value, SecondLevelDomainWhitelist), - err => [] // ignore missing or binary file - ); + return this.fileService.resolveFile(uri).then(() => { + return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( + content => getDomainsOfRemotes(content.value, SecondLevelDomainWhitelist), + err => [] // ignore missing or binary file + ); + }, err => []); })).then(domains => { const set = domains.reduce((set, list) => list.reduce((set, item) => set.add(item), set), new Set()); const list: string[] = []; @@ -388,10 +392,12 @@ export class WorkspaceStats implements IWorkbenchContribution { return TPromise.join(workspaceUris.map(workspaceUri => { const path = workspaceUri.path; const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/pom.xml` }); - return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( - content => !!content.value.match(/azure/i), - err => false - ); + return this.fileService.resolveFile(uri).then(stats => { + return this.fileService.resolveContent(uri, { acceptTextOnly: true }).then( + content => !!content.value.match(/azure/i), + err => false + ); + }, err => false); })).then(javas => { if (javas.indexOf(true) !== -1) { tags['java'] = true;