From: William Morgan Date: Fri, 4 Sep 2009 14:29:13 +0000 (-0400) Subject: bugfix: crypto return values when no gpg binary detected X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=927b7df4b2052a6b3c2ae1f2b44a6bc901315f8d;hp=98a26cf7993745ba185f4b4e3852135188460ada;p=sup bugfix: crypto return values when no gpg binary detected Tweak the return values of CryptoManager#decrypt so that the notice widget is the first thing returned regardless. Makes the code cleaner. --- diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb index 7f044b9..772b8b6 100644 --- a/lib/sup/crypto.rb +++ b/lib/sup/crypto.rb @@ -129,10 +129,9 @@ class CryptoManager end notice = Chunk::CryptoNotice.new :valid, "This message has been decrypted for display" - [RMail::Parser.read(decrypted_payload), sig, notice] + [notice, sig, RMail::Parser.read(decrypted_payload)] else - notice = Chunk::CryptoNotice.new :invalid, "This message could not be decrypted", output.split("\n") - [nil, nil, notice] + Chunk::CryptoNotice.new :invalid, "This message could not be decrypted", output.split("\n") end end diff --git a/lib/sup/message.rb b/lib/sup/message.rb index ed27d3d..426eb80 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -382,9 +382,13 @@ private return end - decryptedm, sig, notice = CryptoManager.decrypt payload - children = message_to_chunks(decryptedm, true) if decryptedm - [notice, sig, children].flatten.compact + notice, sig, decryptedm = CryptoManager.decrypt payload + if decryptedm # managed to decrypt + children = message_to_chunks(decryptedm, true) + [notice, sig, children] + else + [notice] + end end ## takes a RMail::Message, breaks it into Chunk:: classes.