aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg/GpgKeyGetter.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-16 07:11:32 +0000
committersaturneric <[email protected]>2023-12-16 07:11:32 +0000
commit08dd9b43481d189c60acc58941005dc25a58c77f (patch)
tree38e79c1a255339d9a80f39c8dbbd94a28ec124b7 /src/core/function/gpg/GpgKeyGetter.cpp
parentfix: use secure memory management at impl class (diff)
downloadGpgFrontend-08dd9b43481d189c60acc58941005dc25a58c77f.tar.gz
GpgFrontend-08dd9b43481d189c60acc58941005dc25a58c77f.zip
fix: repair test cases
Diffstat (limited to 'src/core/function/gpg/GpgKeyGetter.cpp')
-rw-r--r--src/core/function/gpg/GpgKeyGetter.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp
index 8ce3c4fa..de8895d9 100644
--- a/src/core/function/gpg/GpgKeyGetter.cpp
+++ b/src/core/function/gpg/GpgKeyGetter.cpp
@@ -76,13 +76,18 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
}
auto FetchKey() -> KeyLinkListPtr {
- // get the lock
- std::lock_guard<std::mutex> lock(keys_cache_mutex_);
+ if (keys_cache_.empty()) {
+ FlushKeyCache();
+ }
auto keys_list = std::make_unique<GpgKeyLinkList>();
- for (const auto& [key, value] : keys_cache_) {
- keys_list->push_back(value);
+ {
+ // get the lock
+ std::lock_guard<std::mutex> lock(keys_cache_mutex_);
+ for (const auto& [key, value] : keys_cache_) {
+ keys_list->push_back(value);
+ }
}
return keys_list;
}