diff options
author | Saturneric <[email protected]> | 2023-04-05 05:16:26 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-04-05 05:16:26 +0000 |
commit | 25dc98b395cbd4e60c468d82de7e2c7579350e58 (patch) | |
tree | 029683a56ad773aa915c32c93a1bf848def4a7a2 /src/init.cpp | |
parent | fix: remove 'cached' in codeql ci (diff) | |
download | GpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.tar.gz GpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.zip |
feat: simplify settings lookup
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/init.cpp b/src/init.cpp index 955b8a55..ddab4add 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -32,6 +32,7 @@ #include <spdlog/sinks/stdout_color_sinks.h> #include <filesystem> +#include <string> #include "GpgFrontend.h" #include "GpgFrontendBuildInfo.h" @@ -90,26 +91,14 @@ void shutdown_logging_system() { } void init_global_path_env() { - auto &settings = - GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings(); - - bool use_custom_gnupg_install_path = false; - try { - use_custom_gnupg_install_path = - settings.lookup("general.use_custom_gnupg_install_path"); - } catch (...) { - SPDLOG_ERROR("setting operation error: use_custom_gnupg_install_path"); - } - - // read from settings file - std::string custom_gnupg_install_path; - try { - custom_gnupg_install_path = static_cast<std::string>( - settings.lookup("general.custom_gnupg_install_path")); - - } catch (...) { - SPDLOG_ERROR("setting operation error: custom_gnupg_install_path"); - } + // read settings + bool use_custom_gnupg_install_path = + GpgFrontend::GlobalSettingStation::GetInstance().LookupSettings( + "general.use_custom_gnupg_install_path", false); + + std::string custom_gnupg_install_path = + GpgFrontend::GlobalSettingStation::GetInstance().LookupSettings( + "general.custom_gnupg_install_path", std::string{}); // add custom gnupg install path into env $PATH if (use_custom_gnupg_install_path && !custom_gnupg_install_path.empty()) { |