Skip to content

Commit

Permalink
Add the Attestation object to the session
Browse files Browse the repository at this point in the history
  • Loading branch information
di committed Aug 30, 2024
1 parent f7e277e commit fa1bd58
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions warehouse/attestations/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ def generate_provenance(
provenance = Provenance(attestation_bundles=[attestation_bundle])

for attestation in attestations:
database_attestation = DatabaseAttestation(
file=file,
attestation_file_blake2_digest=hashlib.blake2b(
attestation.model_dump_json().encode("utf-8")
).hexdigest(),
self.db.add(
DatabaseAttestation(
file=file,
attestation_file_blake2_digest=hashlib.blake2b(
attestation.model_dump_json().encode("utf-8")
).hexdigest(),
)
)

file.attestations.append(database_attestation)

return provenance

def get_provenance_digest(self, file: File) -> str | None:
Expand Down Expand Up @@ -241,6 +241,7 @@ def parse_attestations(
def generate_provenance(
self, request: Request, file: File, attestations: list[Attestation]
) -> Provenance | None:

# Generate the provenance object.
provenance = self._build_provenance_object(request.oidc_publisher, attestations)

Expand Down Expand Up @@ -276,15 +277,14 @@ def _persist_attestations(
database_attestation = DatabaseAttestation(
file=file, attestation_file_blake2_digest=attestation_digest
)
self.db.add(database_attestation)

self.storage.store(
database_attestation.attestation_path,
tmp_file.name,
meta=None,
)

file.attestations.append(database_attestation)

def _build_provenance_object(
self, oidc_publisher: OIDCPublisher, attestations: list[Attestation]
) -> Provenance | None:
Expand Down

0 comments on commit fa1bd58

Please sign in to comment.