From fb38d6f278a4a391b8db1a16ee5946db3766459c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 10 Apr 2026 16:37:46 +0200 Subject: [PATCH] common : fix when loading a cached HF models with unavailable API (#21670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- common/download.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/download.cpp b/common/download.cpp index 561164591f..b9e5097123 100644 --- a/common/download.cpp +++ b/common/download.cpp @@ -283,6 +283,13 @@ static int common_download_file_single_online(const std::string & url, static const int max_attempts = 3; static const int retry_delay_seconds = 2; + const bool file_exists = std::filesystem::exists(path); + + if (file_exists && skip_etag) { + LOG_DBG("%s: using cached file: %s\n", __func__, path.c_str()); + return 304; // 304 Not Modified - fake cached response + } + auto [cli, parts] = common_http_client(url); httplib::Headers headers; @@ -297,13 +304,6 @@ static int common_download_file_single_online(const std::string & url, } cli.set_default_headers(headers); - const bool file_exists = std::filesystem::exists(path); - - if (file_exists && skip_etag) { - LOG_DBG("%s: using cached file: %s\n", __func__, path.c_str()); - return 304; // 304 Not Modified - fake cached response - } - std::string last_etag; if (file_exists) { last_etag = read_etag(path);