diff options
Diffstat (limited to 'alot/commands/envelope.py')
-rw-r--r-- | alot/commands/envelope.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index af0705bc..ccdbae65 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -482,18 +482,12 @@ class EncryptCommand(Command): if self.action == 'rmencrypt': try: for keyid in self.encrypt_keys: - # this is not so nice, but pygpgme doesn't supply a - # __cmp__() operator so list.remove(x) doesn't work - del envelope.encrypt_keys[int(keyid) - 1] + tmp_key = crypto.get_key(keyid) + del envelope.encrypt_keys[crypto.hash_key(tmp_key)] except gpgme.GpgmeError as e: if e.code == gpgme.ERR_INV_VALUE: - raise GPGProblem("Can not find key to encrypt.") + raise GPGProblem("Can not find key to remove.") raise GPGProblem(str(e)) - except ValueError as e: - raise Warning("Enter a the index of the key as argument to " + - "rmencrypt.") - except IndexError as e: - raise Warning("There are not so many encryption keys.") ui.current_buffer.rebuild() return elif self.action == 'encrypt': @@ -508,10 +502,12 @@ class EncryptCommand(Command): # cache all keys before appending to envelope, since otherwise # we get an error message but all earlier keys are added, but # not shown - keys = [] + keys = dict() for keyid in self.encrypt_keys: - keys.append(crypto.get_key(keyid)) - envelope.encrypt_keys.extend(keys) + tmp_key = crypto.get_key(keyid) + keys[crypto.hash_key(tmp_key)] = tmp_key + + envelope.encrypt_keys.update(keys) except gpgme.GpgmeError as e: if e.code == gpgme.ERR_INV_VALUE: raise GPGProblem("Can not find key to encrypt.") |