net: Increase store load timeout to 30 seconds
This commit is contained in:
parent
a8e83154f0
commit
7d9c24ff51
@ -35,11 +35,13 @@ namespace hex {
|
||||
Net();
|
||||
~Net();
|
||||
|
||||
std::future<Response<std::string>> getString(const std::string &url, u32 timeout = 2000);
|
||||
std::future<Response<nlohmann::json>> getJson(const std::string &url, u32 timeout = 2000);
|
||||
static constexpr u32 DefaultTimeout = 2'000;
|
||||
|
||||
std::future<Response<std::string>> uploadFile(const std::string &url, const fs::path &filePath, u32 timeout = 2000);
|
||||
std::future<Response<void>> downloadFile(const std::string &url, const fs::path &filePath, u32 timeout = 2000);
|
||||
std::future<Response<std::string>> getString(const std::string &url, u32 timeout = DefaultTimeout);
|
||||
std::future<Response<nlohmann::json>> getJson(const std::string &url, u32 timeout = DefaultTimeout);
|
||||
|
||||
std::future<Response<std::string>> uploadFile(const std::string &url, const fs::path &filePath, u32 timeout = DefaultTimeout);
|
||||
std::future<Response<void>> downloadFile(const std::string &url, const fs::path &filePath, u32 timeout = DefaultTimeout);
|
||||
|
||||
[[nodiscard]] std::string encode(const std::string &input);
|
||||
|
||||
|
@ -121,7 +121,7 @@ namespace hex {
|
||||
std::optional<i32> Net::execute() {
|
||||
CURLcode result = curl_easy_perform(this->m_ctx);
|
||||
if (result != CURLE_OK)
|
||||
log::error("Net request failed with error {}!", curl_easy_strerror(result));
|
||||
log::error("Net request failed with error {0}: '{1}'", result, curl_easy_strerror(result));
|
||||
|
||||
i32 responseCode = 0;
|
||||
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||
|
@ -37,6 +37,9 @@ namespace hex::plugin::builtin {
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
[[nodiscard]] ImVec2 getMinSize() const override { return { 500, 400 }; }
|
||||
[[nodiscard]] ImVec2 getMaxSize() const override { return { 500, 400 }; }
|
||||
|
||||
private:
|
||||
Net m_net;
|
||||
std::future<Response<std::string>> m_apiRequest;
|
||||
|
@ -161,7 +161,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_yara.clear();
|
||||
this->m_encodings.clear();
|
||||
|
||||
this->m_apiRequest = this->m_net.getString(ImHexApiURL + "/store"s);
|
||||
this->m_apiRequest = this->m_net.getString(ImHexApiURL + "/store"s, 30'0000);
|
||||
}
|
||||
|
||||
void ViewStore::parseResponse() {
|
||||
@ -218,8 +218,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewStore::drawContent() {
|
||||
ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(600, 400)), ImVec2(FLT_MAX, FLT_MAX));
|
||||
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.store.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.store.name").c_str(), &this->getWindowOpenState())) {
|
||||
if (this->m_apiRequest.valid()) {
|
||||
if (this->m_apiRequest.wait_for(0s) != std::future_status::ready)
|
||||
ImGui::TextSpinner("hex.builtin.view.store.loading"_lang);
|
||||
@ -242,7 +241,7 @@ namespace hex::plugin::builtin {
|
||||
if (!update || fs::exists(fullPath)) {
|
||||
downloading = true;
|
||||
this->m_downloadPath = fullPath;
|
||||
this->m_download = this->m_net.downloadFile(url, fullPath);
|
||||
this->m_download = this->m_net.downloadFile(url, fullPath, 30'0000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user