未验证 提交 cd9ea648 编写于 作者: J Jackson Kearl 提交者: GitHub

Trusted Domains: Timeout filesystem access (#100419)

* Adds a timeout for trying to resolve remotes

This needs a better fix, but for remote file systems that require auth this can cause issues if auth requires opening a url

* Reduce timeout
Co-authored-by: NEric Amodio <eamodio@microsoft.com>
上级 78ea4488
......@@ -144,16 +144,18 @@ export function extractGitHubRemotesFromGitConfig(gitConfig: string): string[] {
async function getRemotes(fileService: IFileService, textFileService: ITextFileService, contextService: IWorkspaceContextService): Promise<string[]> {
const workspaceUris = contextService.getWorkspace().folders.map(folder => folder.uri);
const domains = await Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
const exists = await fileService.exists(uri);
if (!exists) {
return [];
}
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
return extractGitHubRemotesFromGitConfig(gitConfig);
}));
const domains = await Promise.race([
new Promise<string[][]>(resolve => setTimeout(() => resolve([]), 250)),
Promise.all<string[]>(workspaceUris.map(async workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
const exists = await fileService.exists(uri);
if (!exists) {
return [];
}
const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
return extractGitHubRemotesFromGitConfig(gitConfig);
}))]);
const set = domains.reduce((set, list) => list.reduce((set, item) => set.add(item), set), new Set<string>());
return [...set];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册