Skip to content

Commit

Permalink
Metadata API: Stop using a deprecated method
Browse files Browse the repository at this point in the history
persist_temp_file() is deprecated, and seemingly not very useful.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
  • Loading branch information
jku committed Apr 12, 2024
1 parent 2d6fc74 commit 3605eaf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tuf/api/metadata.py
Expand Up @@ -36,7 +36,6 @@

from securesystemslib.signer import Signature, Signer
from securesystemslib.storage import FilesystemBackend, StorageBackendInterface
from securesystemslib.util import persist_temp_file

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

if storage_backend is None:
storage_backend = FilesystemBackend()

bytes_data = self.to_bytes(serializer)

with tempfile.TemporaryFile() as temp_file:
temp_file.write(bytes_data)
persist_temp_file(temp_file, filename, storage_backend)
storage_backend.put(temp_file, filename)

# Signatures.
def sign(
Expand Down

0 comments on commit 3605eaf

Please sign in to comment.