Lazy import proxy-agent

This commit is contained in:
Fedor Indutny 2024-03-20 11:05:10 -07:00 committed by GitHub
parent 83e8f4b59d
commit 091b50c414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 60 additions and 39 deletions

View file

@ -15,6 +15,7 @@ import { strictAssert } from '../util/assert';
import { wrapEventEmitterOnce } from '../util/wrapEventEmitterOnce';
import type { LoggerType } from '../types/Logging';
import { getGotOptions } from './got';
import type { GotOptions } from './got';
import { checkIntegrity } from './util';
const gunzip = promisify(nativeGunzip);
@ -74,7 +75,7 @@ export type DownloadOptionsType = Readonly<{
logger?: LoggerType;
// Testing
gotOptions?: ReturnType<typeof getGotOptions>;
gotOptions?: GotOptions;
}>;
export type DownloadRangesOptionsType = Readonly<{
@ -86,7 +87,7 @@ export type DownloadRangesOptionsType = Readonly<{
chunkStatusCallback: (chunkSize: number) => void;
// Testing
gotOptions?: ReturnType<typeof getGotOptions>;
gotOptions?: GotOptions;
}>;
export function getBlockMapFileName(fileName: string): string {
@ -212,7 +213,7 @@ export async function prepareDownload({
const newBlockMapData = await got(
getBlockMapFileName(newUrl),
getGotOptions()
await getGotOptions()
).buffer();
const newBlockMap = await parseBlockMap(newBlockMapData);
@ -343,7 +344,7 @@ export async function downloadRanges(
logger,
abortSignal,
chunkStatusCallback,
gotOptions = getGotOptions(),
gotOptions = await getGotOptions(),
} = options;
logger?.info('updater/downloadRanges: downloading ranges', ranges.length);