]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
common : fix when loading a cached HF models with unavailable API (#21670)
authorAdrien Gallouët <redacted>
Fri, 10 Apr 2026 14:37:46 +0000 (16:37 +0200)
committerGitHub <redacted>
Fri, 10 Apr 2026 14:37:46 +0000 (16:37 +0200)
Signed-off-by: Adrien Gallouët <redacted>
common/download.cpp

index 561164591fa3964fc7d0ddfed221610bfbef39d3..b9e509712319473bb63e000dd189240b160cea73 100644 (file)
@@ -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);