hyprpm: handle failed compilations gracefully

This commit is contained in:
vaxerski
2024-01-07 18:15:51 +01:00
parent 7904188de9
commit 9f2bde925b
4 changed files with 24 additions and 8 deletions

View File

@@ -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<SPluginRepository> 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);