diff --git a/gpgtool b/gpgtool index 62a3948..b95a3da 100755 --- a/gpgtool +++ b/gpgtool @@ -156,9 +156,14 @@ open () { key=$(ls ${keypath}/${id}/*.key) [[ $? != 0 ]] && \ echo "${id} does not seem to be a valid key folder, aborting …" && exit 1 - gpg --homedir "${tempdir}/gpghome" --import-options keep-ownertrust \ - --import "${keypath}/${id}/${id}.private.asc" - [[ $? == 0 ]] && ln -sf ${key} ${tempdir}/gpghome/private-keys-v1.d/ + if [[ -f "${tempdir}/gpghome/private-keys-v1.d/$(basename ${key})" ]] + then + echo "Key ${id} already opened." + else + gpg --homedir "${tempdir}/gpghome" --import-options keep-ownertrust \ + --import "${keypath}/${id}/${id}.private.asc" + [[ $? == 0 ]] && ln -sf ${key} ${tempdir}/gpghome/private-keys-v1.d/ + fi done }