Skip check if extract hash from url are failed

This commit is contained in:
2024-06-06 16:07:22 +08:00
parent b7df7ba8ff
commit e59716f552

View File

@@ -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();
}
}
}
}