Преглед изворни кода

arg : -hf do not fail if url mismatch (#13219)

* arg : -hf do not fail if url mismatch

* do not return if cannot parse metadata json
Xuan-Son Nguyen пре 8 месеци
родитељ
комит
6f67cf1f48
1 измењених фајлова са 2 додато и 9 уклоњено
  1. 2 9
      common/arg.cpp

+ 2 - 9
common/arg.cpp

@@ -287,13 +287,6 @@ static bool common_download_file_single(const std::string & url, const std::stri
             try {
             try {
                 metadata_in >> metadata;
                 metadata_in >> metadata;
                 LOG_DBG("%s: previous metadata file found %s: %s\n", __func__, metadata_path.c_str(), metadata.dump().c_str());
                 LOG_DBG("%s: previous metadata file found %s: %s\n", __func__, metadata_path.c_str(), metadata.dump().c_str());
-                if (metadata.contains("url") && metadata.at("url").is_string()) {
-                    auto previous_url = metadata.at("url").get<std::string>();
-                    if (previous_url != url) {
-                        LOG_ERR("%s: Model URL mismatch: %s != %s\n", __func__, url.c_str(), previous_url.c_str());
-                        return false;
-                    }
-                }
                 if (metadata.contains("etag") && metadata.at("etag").is_string()) {
                 if (metadata.contains("etag") && metadata.at("etag").is_string()) {
                     etag = metadata.at("etag");
                     etag = metadata.at("etag");
                 }
                 }
@@ -301,10 +294,10 @@ static bool common_download_file_single(const std::string & url, const std::stri
                     last_modified = metadata.at("lastModified");
                     last_modified = metadata.at("lastModified");
                 }
                 }
             } catch (const nlohmann::json::exception & e) {
             } catch (const nlohmann::json::exception & e) {
-            LOG_ERR("%s: error reading metadata file %s: %s\n", __func__, metadata_path.c_str(), e.what());
-                return false;
+                LOG_ERR("%s: error reading metadata file %s: %s\n", __func__, metadata_path.c_str(), e.what());
             }
             }
         }
         }
+        // if we cannot open the metadata file, we assume that the downloaded file is not valid (etag and last-modified are left empty, so we will download it again)
     } else {
     } else {
         LOG_INF("%s: no previous model file found %s\n", __func__, path.c_str());
         LOG_INF("%s: no previous model file found %s\n", __func__, path.c_str());
     }
     }