🐛 Fix compilation error
This commit is contained in:
parent
3485efee50
commit
89ea7e8246
2 changed files with 20 additions and 15 deletions
|
@ -6,7 +6,7 @@ import checkLocalCache from './funcs/checkLocalCache';
|
||||||
import createDirRecursively from './funcs/createDirRecursively';
|
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. */
|
/** 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 }: {host: string, path: string, size: number, useCurl: boolean}): Promise<string> {
|
export default async function downloadWrapper({ host, path, size, useCurl }: {host: string, path: string, size: number, useCurl: boolean}): Promise<string> {
|
||||||
//Generate file name we want to save it under
|
//Generate file name we want to save it under
|
||||||
//e.g. on Linux: /tmp/patcher/cdn-patch.swtor.com/patch/assets_swtor_main/assets_swtor_main_-1to0/assets_swtor_main_-1to0.zip
|
//e.g. on Linux: /tmp/patcher/cdn-patch.swtor.com/patch/assets_swtor_main/assets_swtor_main_-1to0/assets_swtor_main_-1to0.zip
|
||||||
const tempFileName = nodePath.join(os.tmpdir(), 'patcher', host, path);
|
const tempFileName = nodePath.join(os.tmpdir(), 'patcher', host, path);
|
||||||
|
@ -21,6 +21,7 @@ export default async function downloadWrapper({ host, path, size }: {host: strin
|
||||||
return tempFileName;
|
return tempFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useCurl) {
|
||||||
//Download via curl
|
//Download via curl
|
||||||
//Try up to 15 times
|
//Try up to 15 times
|
||||||
for (let i = 0; i < 15; i += 1) {
|
for (let i = 0; i < 15; i += 1) {
|
||||||
|
@ -36,4 +37,7 @@ export default async function downloadWrapper({ host, path, size }: {host: strin
|
||||||
}
|
}
|
||||||
//Download failed, throw error
|
//Download failed, throw error
|
||||||
throw new Error('Could not download with curl');
|
throw new Error('Could not download with curl');
|
||||||
|
} else {
|
||||||
|
throw new Error('Non-curl download is not yet implemented.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,13 +57,14 @@ export default async function installPatch({ product, from, to, sourceDirectory,
|
||||||
host: 'cdn-patch.swtor.com',
|
host: 'cdn-patch.swtor.com',
|
||||||
path: `/patch/${product.startsWith('retailclient_') ? `${product.substring(13)}/` : ''}${product}/${product}_${from}to${to}/${name}`,
|
path: `/patch/${product.startsWith('retailclient_') ? `${product.substring(13)}/` : ''}${product}/${product}_${from}to${to}/${name}`,
|
||||||
size: length,
|
size: length,
|
||||||
|
useCurl: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//start download, making sure that .zip file downloads first
|
//start download, making sure that .zip file downloads first
|
||||||
const indexOfLastFile = solidpkg.files.length - 1;
|
const indexOfLastFile = solidpkg.files.length - 1;
|
||||||
const zipFile = getUrlContents(createUrlObject(solidpkg.files[indexOfLastFile]));
|
const zipFile = getUrlContents(createUrlObject(solidpkg.files[indexOfLastFile]));
|
||||||
const diskFiles = solidpkg.files.slice(0, indexOfLastFile).map((file) => downloadWrapper.bind(null, createUrlObject(file)));
|
const diskFiles = solidpkg.files.slice(0, indexOfLastFile).map((file) => async function() { await downloadWrapper(createUrlObject(file)); });
|
||||||
|
|
||||||
//we can parse the file entries as soon as the .zip file is downloaded
|
//we can parse the file entries as soon as the .zip file is downloaded
|
||||||
const fileEntries = readSsnFile(await zipFile);
|
const fileEntries = readSsnFile(await zipFile);
|
||||||
|
|
Loading…
Reference in a new issue