Skip to content

Commit 6c55cc0

Browse files
committed
fix: remove unnecessary assert
1 parent be1f218 commit 6c55cc0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/core/function/gpg/GpgKeyGetter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
4646
// find in cache first
4747
if (cache) {
4848
auto key = get_key_in_cache(key_id);
49-
assert(key->KeyType() == GpgAbstractKeyType::kGPG_KEY);
50-
5149
if (key != nullptr) return qSharedPointerDynamicCast<GpgKey>(key);
5250

5351
LOG_W() << "get gpg key" << key_id
@@ -165,11 +163,14 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
165163

166164
for (const auto& s_key : g_key->SubKeys()) {
167165
if (s_key.ID() == g_key->ID()) continue;
168-
auto p_s_key = QSharedPointer<GpgSubKey>::create(s_key);
169166

170167
// don't add adsk key or it will cause bugs
171-
if (p_s_key->IsADSK()) continue;
168+
if (s_key.IsADSK()) continue;
172169

170+
// subkeys should be weaker than primary key
171+
if (keys_search_cache_.contains(s_key.ID())) continue;
172+
173+
auto p_s_key = QSharedPointer<GpgSubKey>::create(s_key);
173174
keys_search_cache_.insert(s_key.ID(), p_s_key);
174175
keys_search_cache_.insert(s_key.Fingerprint(), p_s_key);
175176
}

0 commit comments

Comments
 (0)