From e59716f552109c5ebbfac4eb184b10800abbc7e5 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Thu, 6 Jun 2024 16:07:22 +0800 Subject: [PATCH] Skip check if extract hash from url are failed --- tasks/download.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tasks/download.ts b/tasks/download.ts index 73071c4..d3ed696 100644 --- a/tasks/download.ts +++ b/tasks/download.ts @@ -410,13 +410,20 @@ export async function download_task( } if (manager.cfg.check_file_hash) { const url = re.url; - const hash = getHashFromUrl(url); - const fhash = await calFileSha1(path); - if (hash != fhash) { - console.warn( - `Hash not matched: file hash ${fhash}, original hash ${hash}, url ${url}`, - ); - throw new HashError(); + let hash: string | null = null; + try { + hash = getHashFromUrl(url); + } catch (e) { + console.warn(e); + } + if (hash) { + const fhash = await calFileSha1(path); + if (hash != fhash) { + console.warn( + `Hash not matched: file hash ${fhash}, original hash ${hash}, url ${url}`, + ); + throw new HashError(); + } } } }