From 06cbb13269ed80f771c73adac23dde00e26cf44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Tue, 22 Apr 2025 12:51:01 +0200 Subject: [PATCH] Use a specific error if no signatures files are found --- dangerzone/updater/signatures.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dangerzone/updater/signatures.py b/dangerzone/updater/signatures.py index e4cf5d7..b97a550 100644 --- a/dangerzone/updater/signatures.py +++ b/dangerzone/updater/signatures.py @@ -358,12 +358,21 @@ def load_and_verify_signatures( pubkey_signatures = signatures_path / get_file_digest(pubkey) if not pubkey_signatures.exists(): msg = ( - f"Cannot find a '{pubkey_signatures}' folder." + f"Cannot find a '{pubkey_signatures}' folder. " "You might need to download the image signatures first." ) raise errors.SignaturesFolderDoesNotExist(msg) - with open(pubkey_signatures / f"{image_digest}.json") as f: + signatures_file = pubkey_signatures / f"{image_digest}.json" + + if not signatures_file.exists(): + msg = ( + f"Cannot find a '{signatures_file}' file. " + "You might need to download the image signatures first." + ) + raise errors.LocalSignatureNotFound(msg) + + with open(signatures_file) as f: log.debug("Loading signatures from %s", f.name) signatures = json.load(f)