diff --git a/plugins/builtin/include/content/views/view_store.hpp b/plugins/builtin/include/content/views/view_store.hpp index 2d41b3011..d56aa0e8b 100644 --- a/plugins/builtin/include/content/views/view_store.hpp +++ b/plugins/builtin/include/content/views/view_store.hpp @@ -71,6 +71,7 @@ namespace hex::plugin::builtin { bool download(const paths::impl::DefaultPath *pathType, const std::string &fileName, const std::string &url); bool remove(const paths::impl::DefaultPath *pathType, const std::string &fileName); + void updateAll(); private: HttpRequest m_httpRequest = HttpRequest("GET", ""); diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 4a02447a3..15a306f20 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -52,6 +52,16 @@ namespace hex::plugin::builtin { ThemeManager::addTheme(themeFile.readString()); }); addCategory("hex.builtin.view.store.tab.yara", "yara", &paths::Yara); + + TaskManager::doLater([this] { + // Force update all installed items after an update so that there's no old and incompatible versions around anymore + { + const auto prevUpdateVersion = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.prev_launch_version", ""); + if (prevUpdateVersion != ImHexApi::System::getImHexVersion()) { + updateAll(); + } + } + }); } @@ -197,28 +207,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - 25_scaled); ImGui::BeginDisabled(m_updateAllTask.isRunning() || m_updateCount == 0); if (ImGuiExt::IconButton(ICON_VS_CLOUD_DOWNLOAD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { - m_updateAllTask = TaskManager::createTask("hex.builtin.task.updating_store"_lang, m_updateCount, [this](auto &task) { - for (auto &category : m_categories) { - for (auto &entry : category.entries) { - if (entry.hasUpdate) { - entry.downloading = this->download(category.path, entry.fileName, entry.link); - if (!m_download.valid()) - continue; - - m_download.wait(); - - while (m_download.valid() && m_download.wait_for(100ms) != std::future_status::ready) { - task.update(); - } - - entry.hasUpdate = false; - entry.downloading = false; - - task.increment(); - } - } - } - }); + this->updateAll(); } ImGuiExt::InfoTooltip(hex::format("hex.builtin.view.store.update_count"_lang, m_updateCount.load()).c_str()); @@ -346,6 +335,36 @@ namespace hex::plugin::builtin { return removed; } + void ViewStore::updateAll() { + m_updateAllTask = TaskManager::createTask("hex.builtin.task.updating_store"_lang, m_updateCount, [this](auto &task) { + for (auto &category : m_categories) { + for (auto &entry : category.entries) { + if (entry.hasUpdate) { + entry.downloading = this->download(category.path, entry.fileName, entry.link); + if (!m_download.valid()) + continue; + + m_download.wait(); + + while (m_download.valid() && m_download.wait_for(100ms) != std::future_status::ready) { + task.update(); + } + + entry.hasUpdate = false; + entry.downloading = false; + + task.increment(); + } + } + } + + TaskManager::doLater([] { + ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.prev_launch_version", ImHexApi::System::getImHexVersion()); + }); + }); + } + + void ViewStore::addCategory(const UnlocalizedString &unlocalizedName, const std::string &requestName, const paths::impl::DefaultPath *path, std::function downloadCallback) { m_categories.push_back({ unlocalizedName, requestName, path, { }, std::move(downloadCallback) }); }