only add etag is dst file already exists, enable curl --compressed option.
curl/libcurl does not send Accept-Encoding by default. many servers support sending compressed versions of files, to speed up transfers. this is ideal for the switch as its io is shit, but the cpu is mostly idle (4% cpu usage for sphaira). github and appstore support sending gzip json files, themezer doesn't seem to.
This commit is contained in:
@@ -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()))) {
|
||||
|
||||
Reference in New Issue
Block a user