diff --git a/sphaira/source/download.cpp b/sphaira/source/download.cpp index e3a96b2..61c15c1 100644 --- a/sphaira/source/download.cpp +++ b/sphaira/source/download.cpp @@ -473,7 +473,8 @@ auto DownloadInternal(CURL* curl, const Api& e) -> ApiResult { return {}; } - if (e.GetFlags() & Flag_Cache) { + // only add etag if the dst file still exists. + if ((e.GetFlags() & Flag_Cache) && fs::FileExists(&fs.m_fs, e.GetPath())) { g_cache.get(e.GetPath(), header_in); } } @@ -492,6 +493,8 @@ auto DownloadInternal(CURL* curl, const Api& e) -> ApiResult { CURL_EASY_SETOPT_LOG(curl, CURLOPT_BUFFERSIZE, 1024*512); CURL_EASY_SETOPT_LOG(curl, CURLOPT_HEADERFUNCTION, header_callback); CURL_EASY_SETOPT_LOG(curl, CURLOPT_HEADERDATA, &header_out); + // enable all forms of compression supported by libcurl. + CURL_EASY_SETOPT_LOG(curl, CURLOPT_ACCEPT_ENCODING, ""); if (has_post) { CURL_EASY_SETOPT_LOG(curl, CURLOPT_POSTFIELDS, e.GetFields().c_str()); @@ -560,6 +563,15 @@ auto DownloadInternal(CURL* curl, const Api& e) -> ApiResult { g_cache.set(e.GetPath(), header_out); } + // enable to log received headers. + #if 0 + log_write("\n\nLOGGING HEADER\n"); + for (auto [a, b] : header_out.m_map) { + log_write("\t%s: %s\n", a.c_str(), b.c_str()); + } + log_write("\n\n"); + #endif + fs.DeleteFile(e.GetPath()); fs.CreateDirectoryRecursivelyWithPath(e.GetPath()); if (R_FAILED(fs.RenameFile(tmp_buf, e.GetPath()))) {