sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 02fbc3c8bb5e82a3ea67c2dd239bc3ccca36049e
parent c255397f39e84344497433969e66af74442055e6
Author: William Morgan <william@twitter.com>
Date:   Wed, 19 Jan 2011 15:47:28 -0800

fix gpgme check

It works as is in 1.9, but in 1.8 it was throwing an exception for even
referencing GPGME::Error if gpgme wasn't installed.

Diffstat:
M lib/sup/crypto.rb | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -43,13 +43,19 @@ EOS
     @mutex = Mutex.new
 
     # test if the gpgme gem is available
-    @gpgme_present = true
-    begin
-    GPGME.check_version({:protocol => GPGME::PROTOCOL_OpenPGP})
-    rescue NameError, GPGME::Error
-      @gpgme_present = false
-      return
-    end
+    @gpgme_present =
+      begin
+        begin
+          GPGME.check_version({:protocol => GPGME::PROTOCOL_OpenPGP})
+          true
+        rescue GPGME::Error
+          false
+        end
+      rescue NameError
+        false
+      end
+
+    return unless @gpgme_present
 
     if (bin = `which gpg2`.chomp) =~ /\S/
       GPGME.set_engine_info GPGME::PROTOCOL_OpenPGP, bin, nil