]> git.ipfire.org Git - pbs.git/commitdiff
API: uploads: Include the digest in hex format
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jun 2025 13:21:36 +0000 (13:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Jun 2025 13:21:36 +0000 (13:21 +0000)
The binary part cannot be serialized in JSON.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/uploads.py

index e0a3292c2c5420c226e485582f91c1887083bd67..150229f52f9545d4fd73e2528234c079bfc091d0 100644 (file)
@@ -6,6 +6,7 @@ import hashlib
 import hmac
 import logging
 import os
+import pydantic
 import shutil
 import sqlalchemy
 import tempfile
@@ -188,7 +189,14 @@ class Upload(sqlmodel.SQLModel, database.BackendMixin, table=True):
 
        # Digest
 
-       digest_blake2b512 : bytes
+       digest_blake2b512 : bytes = sqlmodel.Field(exclude=True)
+
+       # Hexdigest
+
+       @pydantic.computed_field
+       @property
+       def hexdigest_blake2b512(self) -> str:
+               return self.digest_blake2b512.hex()
 
        # Builder ID