diff --git a/loader/include/Geode/utils/web.hpp b/loader/include/Geode/utils/web.hpp index a496c76f..f87313d4 100644 --- a/loader/include/Geode/utils/web.hpp +++ b/loader/include/Geode/utils/web.hpp @@ -130,7 +130,7 @@ namespace geode::utils::web { AsyncExpectCode m_expect = nullptr; AsyncProgress m_progress = nullptr; AsyncCancelled m_cancelled = nullptr; - AsyncWebRequestData* m_extra = nullptr; + mutable AsyncWebRequestData* m_extra = nullptr; std::variant m_target; std::vector m_httpHeaders; diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index ebb52e2e..25b9ddae 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -160,6 +160,7 @@ private: mutable std::mutex m_mutex; AsyncWebRequestData m_extra; + std::variant m_target; std::vector m_httpHeaders; @@ -184,7 +185,7 @@ static std::unordered_map RUNNING_REQUES static std::mutex RUNNING_REQUESTS_MUTEX; SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const& req, std::string const& id) : - m_id(id), m_url(req.m_url), m_extra(req.extra()), m_httpHeaders(req.m_httpHeaders) { + m_id(id), m_url(req.m_url), m_target(req.m_target), m_extra(req.extra()), m_httpHeaders(req.m_httpHeaders) { #define AWAIT_RESUME() \ {\ @@ -218,16 +219,16 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const std::unique_ptr file = nullptr; // into file - if (std::holds_alternative(m_extra.m_target)) { + if (std::holds_alternative(m_target)) { file = std::make_unique( - std::get(m_extra.m_target), std::ios::out | std::ios::binary + std::get(m_target), std::ios::out | std::ios::binary ); curl_easy_setopt(curl, CURLOPT_WRITEDATA, file.get()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, utils::fetch::writeBinaryData); } // into stream - else if (std::holds_alternative(m_extra.m_target)) { - curl_easy_setopt(curl, CURLOPT_WRITEDATA, std::get(m_extra.m_target)); + else if (std::holds_alternative(m_target)) { + curl_easy_setopt(curl, CURLOPT_WRITEDATA, std::get(m_target)); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, utils::fetch::writeBinaryData); } // into memory @@ -334,8 +335,8 @@ void SentAsyncWebRequest::Impl::doCancel() { m_cleanedUp = true; // remove file if downloaded to one - if (std::holds_alternative(m_extra.m_target)) { - auto path = std::get(m_extra.m_target); + if (std::holds_alternative(m_target)) { + auto path = std::get(m_target); if (ghc::filesystem::exists(path)) { try { ghc::filesystem::remove(path);