aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg/function/GpgKeyGetter.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-11-29 02:57:43 +0000
committerSaturneric <[email protected]>2021-11-29 02:57:43 +0000
commitd7e953b25a28a846b0aafa7003f33432b7e107f5 (patch)
tree479f77c85a5fca956a58891eaa87c9afb224db86 /src/gpg/function/GpgKeyGetter.cpp
parentFix some known issues in basic operations and file operations. (diff)
downloadGpgFrontend-d7e953b25a28a846b0aafa7003f33432b7e107f5.tar.gz
GpgFrontend-d7e953b25a28a846b0aafa7003f33432b7e107f5.zip
Fix Known Bugs.
1. Import Keys. 2. Import Keys From Server. 3. UID Management.
Diffstat (limited to '')
-rw-r--r--src/gpg/function/GpgKeyGetter.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp
index ce4c9899..18fbe649 100644
--- a/src/gpg/function/GpgKeyGetter.cpp
+++ b/src/gpg/function/GpgKeyGetter.cpp
@@ -23,16 +23,20 @@
*/
#include "gpg/function/GpgKeyGetter.h"
+
#include <gpg-error.h>
+
#include "GpgConstants.h"
GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetKey(const std::string& fpr) {
gpgme_key_t _p_key;
gpgme_get_key(ctx, fpr.c_str(), &_p_key, 1);
- if (_p_key == nullptr)
- DLOG(WARNING) << "GpgKeyGetter GetKey _p_key Null";
- assert(_p_key != nullptr);
- return GpgKey(std::move(_p_key));
+ if (_p_key == nullptr) {
+ DLOG(WARNING) << "GpgKeyGetter GetKey Private _p_key Null fpr" << fpr;
+ return GetPubkey(fpr);
+ } else {
+ return GpgKey(std::move(_p_key));
+ }
}
GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetPubkey(
@@ -40,7 +44,7 @@ GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetPubkey(
gpgme_key_t _p_key;
gpgme_get_key(ctx, fpr.c_str(), &_p_key, 0);
if (_p_key == nullptr)
- DLOG(WARNING) << "GpgKeyGetter GetKey _p_key Null";
+ DLOG(WARNING) << "GpgKeyGetter GetKey _p_key Null" << fpr;
return GpgKey(std::move(_p_key));
}
@@ -66,7 +70,6 @@ GpgFrontend::KeyLinkListPtr GpgFrontend::GpgKeyGetter::FetchKey() {
GpgFrontend::KeyListPtr GpgFrontend::GpgKeyGetter::GetKeys(
const KeyIdArgsListPtr& ids) {
auto keys = std::make_unique<KeyArgsList>();
- for (const auto& id : *ids)
- keys->push_back(GetKey(id));
+ for (const auto& id : *ids) keys->push_back(GetKey(id));
return keys;
}