Qt: Use HTTPCache downloader for DownloadFile()

pull/3715/head
Stenzek 5 months ago
parent 80b93d3e04
commit 1260891e4f
No known key found for this signature in database

@ -12,6 +12,7 @@
#include "core/core.h"
#include "util/http_downloader.h"
#include "util/http_cache.h"
#include "util/translation.h"
#include "common/assert.h"
@ -126,7 +127,7 @@ AutoUpdaterDialog::AutoUpdaterDialog(QWidget* const parent, Error* const error)
connect(m_ui.skipThisUpdate, &QPushButton::clicked, this, &AutoUpdaterDialog::skipThisUpdateClicked);
connect(m_ui.remindMeLater, &QPushButton::clicked, this, &AutoUpdaterDialog::remindMeLaterClicked);
m_http = HTTPDownloader::Create(Core::GetHTTPUserAgent(), error);
m_http = HTTPDownloader::Create(HTTPCache::GetUserAgent(), error);
m_http_poll_timer = new QTimer(this);
m_http_poll_timer->connect(m_http_poll_timer, &QTimer::timeout, this, &AutoUpdaterDialog::httpPollTimerPoll);

@ -50,6 +50,7 @@
#include "util/audio_stream.h"
#include "util/cd_image.h"
#include "util/http_cache.h"
#include "util/http_downloader.h"
#include "util/imgui_manager.h"
#include "util/ini_settings_interface.h"
@ -740,11 +741,11 @@ void QtHost::DownloadFile(QWidget* parent, std::string url, std::string path,
[url = std::move(url), path = std::move(path),
completion_callback = std::move(completion_callback)](ProgressCallback* const progress) mutable {
Error error;
std::unique_ptr<HTTPDownloader> http = HTTPDownloader::Create(Core::GetHTTPUserAgent(), &error);
bool result;
if ((result = static_cast<bool>(http)))
bool result = false;
if (const auto downloader = HTTPCache::GetDownloader(&error))
{
http->CreateRequest(
result = true;
downloader->CreateRequest(
std::move(url),
[&result, &error, &path](s32 status_code, const Error& http_error, const std::string&,
std::vector<u8> hdata) {
@ -762,11 +763,11 @@ void QtHost::DownloadFile(QWidget* parent, std::string url, std::string path,
result = FileSystem::WriteBinaryFile(path.c_str(), hdata, &error);
},
progress);
// Block until completion.
http->WaitForAllRequests();
}
// Block until completion.
HTTPCache::WaitForAllRequests();
QtAsyncTaskWithProgressDialog::CompletionCallback ret;
if (completion_callback)
{

Loading…
Cancel
Save