Skip to content

Commit f8074b9

Browse files
ochafikochafik
andcommitted
merge branches
Co-Authored-By: ochafik <[email protected]>
1 parent 0818ab2 commit f8074b9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

common/arg.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ static bool common_download_file_single(const std::string & url, const std::stri
253253
std::string last_modified;
254254

255255
if (file_exists) {
256+
if (offline) {
257+
LOG_INF("%s: using cached file (offline mode): %s\n", __func__, path.c_str());
258+
return true; // skip verification/downloading
259+
}
256260
// Try and read the JSON metadata file (note: stream autoclosed upon exiting this block).
257261
std::ifstream metadata_in(metadata_path);
258262
if (metadata_in.good()) {
@@ -271,10 +275,11 @@ static bool common_download_file_single(const std::string & url, const std::stri
271275
}
272276
// 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)
273277
} else {
274-
LOG_INF("%s: no previous model file found %s\n", __func__, path.c_str());
275278
if (offline) {
279+
LOG_ERR("%s: required file is not available in cache (offline mode): %s\n", __func__, path.c_str());
276280
return false;
277281
}
282+
LOG_INF("%s: no previous model file found %s\n", __func__, path.c_str());
278283
}
279284

280285
// Send a HEAD request to retrieve the etag and last-modified headers
@@ -283,15 +288,6 @@ static bool common_download_file_single(const std::string & url, const std::stri
283288
std::string last_modified;
284289
};
285290

286-
if (offline) {
287-
if (file_exists) {
288-
LOG_INF("%s: using cached file (offline mode): %s\n", __func__, path.c_str());
289-
return true; // skip verification/downloading
290-
}
291-
LOG_ERR("%s: required file is not available in cache (offline mode): %s\n", __func__, path.c_str());
292-
return false;
293-
}
294-
295291
common_load_model_from_url_headers headers;
296292
bool head_request_ok = false;
297293
bool should_download = !file_exists; // by default, we should download if the file does not exist

0 commit comments

Comments
 (0)