refactor: use Net tasks for github api download

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-06-02 15:15:25 -07:00
parent 5d03919b59
commit 98174b7a37
5 changed files with 90 additions and 56 deletions

View File

@ -131,13 +131,12 @@ void Download::executeTask()
return;
}
#if defined (LAUNCHER_APPLICATION)
auto user_agent = APPLICATION->getUserAgent();
#if defined(LAUNCHER_APPLICATION)
auto user_agent = APPLICATION->getUserAgent().toUtf8();
#else
auto user_agent = BuildConfig.USER_AGENT;
auto user_agent = BuildConfig.USER_AGENT.toUtf8();
#endif
request.setHeader(QNetworkRequest::UserAgentHeader, user_agent.toUtf8());
request.setHeader(QNetworkRequest::UserAgentHeader, user_agent);
for ( auto& header_proxy : m_headerProxies ) {
header_proxy->writeHeaders(request);

View File

@ -59,6 +59,7 @@ class Download : public NetAction {
public:
~Download() override = default;
#if defined(LAUNCHER_APPLICATION)
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
static auto makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options = Option::NoOptions) -> Download::Ptr;
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;