🐎 Continue curl download where it left off

This commit is contained in:
C-3PO 2018-11-16 16:37:07 +01:00
parent 4f70c05567
commit 43d4019860
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -16,7 +16,7 @@ export default function downloadWithCurl({ host, path, tempFileName }: {host: st
const url = `http://${host}${(path[0] === '/' ? '' : '/')}${path}`;
const parameters: string[] = [
//...
'--continue-at', '-',
'--silent',
'--limit-rate', `${MAXIMUM_SPEED}m`,
'--speed-limit', String(MINIMUM_SPEED * 1024 * 1024),
@ -36,7 +36,7 @@ export default function downloadWithCurl({ host, path, tempFileName }: {host: st
if (code === 0) {
resolve(tempFileName);
} else if (code === 28) {
reject(`Download speed too slow, restarting "${path.includes('/') ? path.substr(path.lastIndexOf('/')) : path}".`);
reject(`Download speed too slow, restarting "${path.includes('/') ? path.substr(path.lastIndexOf('/') + 1) : path}".`);
} else {
reject(`Error in process:\n> curl ${parameters.join(' ')}\nNon-zero exit code ${code}.`);
}