Skip to content

Commit 3605eaf

Browse files
committed
Metadata API: Stop using a deprecated method
persist_temp_file() is deprecated, and seemingly not very useful. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 2d6fc74 commit 3605eaf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tuf/api/metadata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
from securesystemslib.signer import Signature, Signer
3838
from securesystemslib.storage import FilesystemBackend, StorageBackendInterface
39-
from securesystemslib.util import persist_temp_file
4039

4140
# Expose payload classes via ``tuf.api.metadata`` to maintain the API,
4241
# even if they are unused in the local scope.
@@ -332,11 +331,14 @@ def to_file(
332331
StorageError: The file cannot be written.
333332
"""
334333

334+
if storage_backend is None:
335+
storage_backend = FilesystemBackend()
336+
335337
bytes_data = self.to_bytes(serializer)
336338

337339
with tempfile.TemporaryFile() as temp_file:
338340
temp_file.write(bytes_data)
339-
persist_temp_file(temp_file, filename, storage_backend)
341+
storage_backend.put(temp_file, filename)
340342

341343
# Signatures.
342344
def sign(

0 commit comments

Comments
 (0)