Commit e3f1745a authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Add memoization for gpg_signatures

parent 988dc4ae
...@@ -48,7 +48,7 @@ module Gitlab ...@@ -48,7 +48,7 @@ module Gitlab
if gpg_key if gpg_key
Gitlab::Gpg::CurrentKeyChain.add(gpg_key.key) Gitlab::Gpg::CurrentKeyChain.add(gpg_key.key)
clear_memoization(:verified_signature) clear_memoization(:gpg_signatures)
end end
yield gpg_key yield gpg_key
...@@ -56,10 +56,6 @@ module Gitlab ...@@ -56,10 +56,6 @@ module Gitlab
end end
def verified_signature def verified_signature
strong_memoize(:verified_signature) { gpgme_signature }
end
def gpgme_signature
gpg_signatures.first gpg_signatures.first
end end
...@@ -73,15 +69,17 @@ module Gitlab ...@@ -73,15 +69,17 @@ module Gitlab
end end
def gpg_signatures def gpg_signatures
signatures = [] strong_memoize(:gpg_signatures) do
signatures = []
GPGME::Crypto.new.verify(signature_text, signed_text: signed_text) do |verified_signature| GPGME::Crypto.new.verify(signature_text, signed_text: signed_text) do |verified_signature|
signatures << verified_signature signatures << verified_signature
end end
signatures signatures
rescue GPGME::Error rescue GPGME::Error
[] []
end
end end
def multiple_signatures? def multiple_signatures?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment