From 910935539fd9035aff89bc9f7bb89da7130c25cc Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 18 Jun 2024 19:38:56 +0800 Subject: [PATCH] Fix model file download --- src/utils/hub.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/utils/hub.js b/src/utils/hub.js index 40c7bb8b5..c11e65b05 100644 --- a/src/utils/hub.js +++ b/src/utils/hub.js @@ -884,18 +884,16 @@ export async function getModelPath(path_or_repo_id, filename, fatal = true, opti file: filename } - if (response === undefined) { - const cachePath = path.join(options.cache_dir ?? env.cacheDir, proposedCacheKey); - await downloadFile(remoteURL, cachePath, data => { - dispatchCallback(options.progress_callback, { - ...progressInfo, - ...data, - }) - }); - response = await getFile(cachePath); - if (response.status !== 200) { - return handleError(response.status, remoteURL, fatal); - } + const cachePath = path.join(options.cache_dir ?? env.cacheDir, proposedCacheKey); + await downloadFile(remoteURL, cachePath, data => { + dispatchCallback(options.progress_callback, { + ...progressInfo, + ...data, + }) + }); + response = await getFile(cachePath); + if (response.status !== 200) { + return handleError(response.status, remoteURL, fatal); } dispatchCallback(options.progress_callback, {