From 582a971b80c8f0515981fe2eb91753822fa63492 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Mon, 8 Jun 2020 23:05:35 +0200 Subject: [PATCH] remove pgp retry mechanism --- app/pgp_utils.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/pgp_utils.py b/app/pgp_utils.py index eb3c0e8a..17616483 100644 --- a/app/pgp_utils.py +++ b/app/pgp_utils.py @@ -43,15 +43,12 @@ def encrypt_file(data: BytesIO, fingerprint: str) -> str: r = gpg.encrypt_file(data, fingerprint, always_trust=True) if not r.ok: - LOG.error("Try encrypt again %s", fingerprint) - r = gpg.encrypt_file(data, fingerprint, always_trust=True) - if not r.ok: - # save the content for debugging - random_file_name = random_string(20) + ".eml" - full_path = f"/tmp/{random_file_name}" - with open(full_path, "wb") as f: - f.write(data.getbuffer()) - LOG.error("PGP fail - log to %s", full_path) - raise PGPException("Cannot encrypt") + # save the content for debugging + random_file_name = random_string(20) + ".eml" + full_path = f"/tmp/{random_file_name}" + with open(full_path, "wb") as f: + f.write(data.getbuffer()) + LOG.error("PGP fail - log to %s", full_path) + raise PGPException("Cannot encrypt") return str(r)