Subject: [sup-talk] [PATCH] decrypt returns 3 elem array if gpg is unavailable

From: [email-masked] (Matt Zulak)
Date: Thu, 3 Sep 2009 12:38:53 -0400

CryptoManager's decrypt method returns a CryptoNotice if the GPG binary
can't be found on the path; however, the Message class expects a 3
element array with either a RMail::Message or nil at index 0.
This patch ensures sup plays nice when importing encrypted messages from
a mail-store on an environment that does not have GPG.
---
 lib/sup/crypto.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
index 7f044b9..afbc445 100644
--- a/lib/sup/crypto.rb
+++ b/lib/sup/crypto.rb
@@ -105,7 +105,7 @@ class CryptoManager
 
   ## returns decrypted_message, status, desc, lines
   def decrypt payload # a RubyMail::Message object
-    return unknown_status(cant_find_binary) unless @cmd
+    return [nil, nil, unknown_status(cant_find_binary)] unless @cmd
 
     payload_fn = Tempfile.new "redwood.payload"
     payload_fn.write payload.to_s
-- 
1.6.2.1

---

From: [email-masked] (William Morgan)
Date: Fri, 04 Sep 2009 07:34:11 -0700

Reformatted excerpts from Matt Zulak's message of 2009-09-03:
> CryptoManager's decrypt method returns a CryptoNotice if the GPG
> binary can't be found on the path; however, the Message class expects
> a 3 element array with either a RMail::Message or nil at index 0.

Thanks. I've fixed this in a slightly different way, by returning the
notice as the first element. I think the code is a little easier to read
that way. Let me know if it doesn't work.
-- 
William <wmorgan-sup at masanjin.net>