diff --git a/gpg_import.py b/gpg_import.py index 8c6c4e5..be109ca 100644 --- a/gpg_import.py +++ b/gpg_import.py @@ -128,7 +128,10 @@ def _debug(self, msg): def _execute_task(self): key_present = False - if self.key_type == 'public': + if self.key_id: + res = self._execute_command('check') + key_present = res['rc'] == 0 + elif self.key_type == 'public': filekey = self._get_key_from_file() if filekey: # rerun the original setup with this key in the commands @@ -144,9 +147,6 @@ def _execute_task(self): res = self._execute_command('check-private') self._debug('checkprivate: %s' % (str(res))) key_present = res['rc'] == 0 - else: - res = self._execute_command('check') - key_present = res['rc'] == 0 if key_present and self.state == 'absent': res = self._execute_command('delete')