Skip to content

Commit 83349c4

Browse files
authored
Linting issue and using try and except block for error handling, and using UnsignedMetadataError from tuf.api.exceptions`
Signed-off-by: Kapil Sharma <ks3913688@gmail.com>
1 parent be4b4ef commit 83349c4

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

tuf/repository/_repository.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from copy import deepcopy
1010
from typing import Dict, Generator, Optional, Tuple
1111

12+
from tuf.api.exceptions import UnsignedMetadataError
1213
from tuf.api.metadata import (
1314
Metadata,
1415
MetaFile,
@@ -191,9 +192,13 @@ def do_snapshot(
191192
root = self.root()
192193
snapshot_md = self.open(Snapshot.type)
193194

194-
if not root.verify_delegate(
195-
Snapshot.type, snapshot_md.signed_bytes(), snapshot_md.signatures
196-
):
195+
try:
196+
root.verify_delegate(
197+
Snapshot.type,
198+
snapshot_md.signed_bytes,
199+
snapshot_md.signatures,
200+
)
201+
except UnsignedMetadataError:
197202
update_version = True
198203

199204
with self.edit_snapshot() as snapshot:
@@ -240,9 +245,13 @@ def do_timestamp(
240245
root = self.root()
241246
timestamp_md = self.open(Timestamp.type)
242247

243-
if not root.verify_delegate(
244-
Timestamp.type, timestamp_md.signed_bytes(), timestamp_md.signatures
245-
):
248+
try:
249+
root.verify_delegate(
250+
Timestamp.type,
251+
timestamp_md.signed_bytes,
252+
timestamp_md.signatures,
253+
)
254+
except UnsignedMetadataError:
246255
update_version = True
247256

248257
with self.edit_timestamp() as timestamp:

0 commit comments

Comments
 (0)