Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions common/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Loading