From 855640c93252dfef8ce69790fb8f4468d0fc6f20 Mon Sep 17 00:00:00 2001 From: nishiki Date: Sun, 8 May 2016 10:25:16 +0200 Subject: [PATCH] auto import public key in mpw file --- lib/mpw/mpw.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index 2c988c5..f99153b 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -45,7 +45,13 @@ class MPW data = decrypt(f.read) when /^wallet\/keys\/(?.+)\.pub$/ - @keys[Regexp.last_match('key')] = f.read + key = Regexp.last_match('key') + + if GPGME::Key.find(:public, key).length == 0 + GPGME::Key.import(f.read, armor: true) + end + + @keys[key] = f.read when /^wallet\/passwords\/(?[a-zA-Z0-9]+)\.gpg$/ @passwords[Regexp.last_match('id')] = f.read @@ -143,7 +149,6 @@ class MPW if not file.nil? and File.exists?(file) data = File.open(file).read GPGME::Key.import(data, armor: true) - puts GPGME::Key.find(key)[0].trust else data = GPGME::Key.export(key, armor: true).read end