Use a specific error if no signatures files are found

This commit is contained in:
Alexis Métaireau 2025-04-22 12:51:01 +02:00
parent 4c9139201f
commit 06cbb13269
No known key found for this signature in database
GPG key ID: C65C7A89A8FFC56E

View file

@ -363,7 +363,16 @@ def load_and_verify_signatures(
)
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)