simplify etag caching requests

This commit is contained in:
ITotalJustice
2024-12-30 02:27:52 +00:00
parent 7804bbbcbc
commit cdb38f27a7
6 changed files with 46 additions and 46 deletions

View File

@@ -145,10 +145,9 @@ MainMenu::MainMenu() {
curl::Api().ToFileAsync(
curl::Url{GITHUB_URL},
curl::Path{CACHE_PATH},
curl::Flags{curl::Flag_Cache},
curl::Header{
{ "Accept", "application/vnd.github+json" },
{ "if-none-match", curl::cache::etag_get(CACHE_PATH) },
{ "if-modified-since", curl::cache::lmt_get(CACHE_PATH) },
},
curl::OnComplete{[this](auto& result){
log_write("inside github download\n");
@@ -165,9 +164,6 @@ MainMenu::MainMenu() {
log_write("etag changed\n");
}
curl::cache::etag_set(result.path, result.header);
curl::cache::lmt_set(result.path, result.header);
auto json = yyjson_read_file(CACHE_PATH, YYJSON_READ_NOFLAG, nullptr, nullptr);
R_UNLESS(json, false);
ON_SCOPE_EXIT(yyjson_doc_free(json));