diff --git a/src/cdn/downloadWrapper.ts b/src/cdn/downloadWrapper.ts index 09774a7..270b29b 100644 --- a/src/cdn/downloadWrapper.ts +++ b/src/cdn/downloadWrapper.ts @@ -6,7 +6,7 @@ import checkLocalCache from './funcs/checkLocalCache'; import createDirRecursively from './funcs/createDirRecursively'; /** Downloads the given URL and saves it to disk. Returns the location where file is saved under. Throws error if download fails. */ -export default async function downloadWrapper({ host, path, size, useCurl = false }: {host: string, path: string, size: number, useCurl: boolean}): string { +export default async function downloadWrapper({ host, path, size, useCurl = false }: {host: string, path: string, size: number, useCurl: boolean}): Promise { //Generate file name we want to save it under //e.g. on Linux: /tmp/patcher/patch/assets_swtor_main/assets_swtor_main_-1to0/assets_swtor_main_-1to0.zip const tempFileName = nodePath.join(os.tmpdir(), 'patcher', host, path); @@ -23,12 +23,14 @@ export default async function downloadWrapper({ host, path, size, useCurl = fals //Download either via curl or natively with Node if (useCurl) { - await new Promise((resolve, reject) => { + const downloadResult = await new Promise((resolve, reject) => { downloadWithCurl({ host, path, tempFileName, size, resolve, reject }); - }); + }) as string; + return downloadResult; } else { - await new Promise((resolve, reject) => { + const downloadResult = await new Promise((resolve, reject) => { downloadUrlContents(host, path, tempFileName, resolve, reject); - }); + }) as string; + return downloadResult; } }