MCPcopy
hub / github.com/dotnet/vscode-csharp / DownloadFile

Function DownloadFile

src/packageManager/fileDownloader.ts:22–53  ·  view source on GitHub ↗
(
    description: string,
    eventStream: EventStream,
    networkSettingsProvider: NetworkSettingsProvider,
    url: string,
    fallbackUrl?: string,
    token?: CancellationToken
)

Source from the content-addressed store, hash-verified

20import { CancellationToken } from 'vscode';
21
22export async function DownloadFile(
23 description: string,
24 eventStream: EventStream,
25 networkSettingsProvider: NetworkSettingsProvider,
26 url: string,
27 fallbackUrl?: string,
28 token?: CancellationToken
29): Promise<Buffer> {
30 eventStream.post(new DownloadStart(description));
31
32 try {
33 const buffer = await downloadFile(description, url, eventStream, networkSettingsProvider, token);
34 eventStream.post(new DownloadSuccess(` Done!`));
35 return buffer;
36 } catch (primaryUrlError) {
37 // If the package has a fallback Url, and downloading from the primary Url failed, try again from
38 // the fallback. This is used for debugger packages as some users have had issues downloading from
39 // the CDN link
40 if (fallbackUrl !== undefined) {
41 eventStream.post(new DownloadFallBack(fallbackUrl));
42 try {
43 const buffer = await downloadFile(description, fallbackUrl, eventStream, networkSettingsProvider);
44 eventStream.post(new DownloadSuccess(' Done!'));
45 return buffer;
46 } catch (_) {
47 throw primaryUrlError;
48 }
49 } else {
50 throw primaryUrlError;
51 }
52 }
53}
54
55async function downloadFile(
56 description: string,

Callers 4

downloadAndGetHashFunction · 0.90
GetLatestVersionMethod · 0.90

Calls 2

downloadFileFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected