From c814f4d1fff3d934586a7e69a72ff78fcc75b3e4 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 16 Nov 2018 05:48:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20error=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cdn/downloadWithCurl.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cdn/downloadWithCurl.ts b/src/cdn/downloadWithCurl.ts index 6e8ed4d..ffa9dee 100644 --- a/src/cdn/downloadWithCurl.ts +++ b/src/cdn/downloadWithCurl.ts @@ -13,7 +13,7 @@ const CHECK_INTERVAL = 15; */ export default function downloadWithCurl({ host, path, tempFileName }: {host: string, path: string, tempFileName: string}): Promise { return new Promise(function(resolve, reject) { - const url = `http://${host}${(path.substr(0, 1) === '/' ? '' : '/')}${path}`; + const url = `http://${host}${(path[0] === '/' ? '' : '/')}${path}`; const parameters: string[] = [ //... @@ -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, will restart "${url}".`); + reject(`Download speed too slow, restarting "${path.includes('/') ? path.substr(path.lastIndexOf('/')) : path}".`); } else { reject(`Error in process:\n> curl ${parameters.join(' ')}\nNon-zero exit code ${code}.`); }