From 9f2bde925bde09b4820a2cef369e9ddd930a746b Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sun, 7 Jan 2024 18:15:51 +0100 Subject: hyprpm: handle failed compilations gracefully --- hyprpm/src/core/DataState.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'hyprpm/src/core/DataState.cpp') diff --git a/hyprpm/src/core/DataState.cpp b/hyprpm/src/core/DataState.cpp index d95f10bb..724c40ac 100644 --- a/hyprpm/src/core/DataState.cpp +++ b/hyprpm/src/core/DataState.cpp @@ -47,7 +47,8 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) { DATA.emplace(p.name, toml::table{ {"filename", p.name + ".so"}, - {"enabled", p.enabled} + {"enabled", p.enabled}, + {"failed", p.failed} }); } // clang-format on @@ -172,9 +173,10 @@ std::vector DataState::getAllRepositories() { continue; const auto ENABLED = STATE[key]["enabled"].value_or(false); + const auto FAILED = STATE[key]["failed"].value_or(false); const auto FILENAME = STATE[key]["filename"].value_or(""); - repo.plugins.push_back(SPlugin{std::string{key.str()}, FILENAME, ENABLED}); + repo.plugins.push_back(SPlugin{std::string{key.str()}, FILENAME, ENABLED, FAILED}); } repos.push_back(repo); @@ -201,6 +203,11 @@ bool DataState::setPluginEnabled(const std::string& name, bool enabled) { if (key.str() != name) continue; + const auto FAILED = STATE[key]["failed"].value_or(false); + + if (FAILED) + return false; + (*STATE[key].as_table()).insert_or_assign("enabled", enabled); std::ofstream state(entry.path().string() + "/state.toml", std::ios::trunc); -- cgit v1.2.3