|
9 | 9 | from copy import deepcopy |
10 | 10 | from typing import Dict, Generator, Optional, Tuple |
11 | 11 |
|
| 12 | +from tuf.api.exceptions import UnsignedMetadataError |
12 | 13 | from tuf.api.metadata import ( |
13 | 14 | Metadata, |
14 | 15 | MetaFile, |
@@ -191,9 +192,13 @@ def do_snapshot( |
191 | 192 | root = self.root() |
192 | 193 | snapshot_md = self.open(Snapshot.type) |
193 | 194 |
|
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: |
197 | 202 | update_version = True |
198 | 203 |
|
199 | 204 | with self.edit_snapshot() as snapshot: |
@@ -240,9 +245,13 @@ def do_timestamp( |
240 | 245 | root = self.root() |
241 | 246 | timestamp_md = self.open(Timestamp.type) |
242 | 247 |
|
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: |
246 | 255 | update_version = True |
247 | 256 |
|
248 | 257 | with self.edit_timestamp() as timestamp: |
|
0 commit comments