Skip to content

Commit fb38d6f

Browse files
authored
common : fix when loading a cached HF models with unavailable API (#21670)
Signed-off-by: Adrien Gallouët <angt@huggingface.co>
1 parent 0893f50 commit fb38d6f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

common/download.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ static int common_download_file_single_online(const std::string & url,
283283
static const int max_attempts = 3;
284284
static const int retry_delay_seconds = 2;
285285

286+
const bool file_exists = std::filesystem::exists(path);
287+
288+
if (file_exists && skip_etag) {
289+
LOG_DBG("%s: using cached file: %s\n", __func__, path.c_str());
290+
return 304; // 304 Not Modified - fake cached response
291+
}
292+
286293
auto [cli, parts] = common_http_client(url);
287294

288295
httplib::Headers headers;
@@ -297,13 +304,6 @@ static int common_download_file_single_online(const std::string & url,
297304
}
298305
cli.set_default_headers(headers);
299306

300-
const bool file_exists = std::filesystem::exists(path);
301-
302-
if (file_exists && skip_etag) {
303-
LOG_DBG("%s: using cached file: %s\n", __func__, path.c_str());
304-
return 304; // 304 Not Modified - fake cached response
305-
}
306-
307307
std::string last_etag;
308308
if (file_exists) {
309309
last_etag = read_etag(path);

0 commit comments

Comments
 (0)