Skip to content

Commit

Permalink
Add CRC32C and MD5 hash for a file
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneGudermann committed Jun 7, 2024
1 parent 56f110b commit 40d4e82
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/viur/core/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ class FileLeafSkel(TreeSkel):
readOnly=True,
visible=False,
)
crc32c_hash = StringBone(
descr="CRC32C hash for this File",
readOnly=True
)
md5_hash = StringBone(
descr="MD5 hash for this File",
readOnly=True
)

def preProcessBlobLocks(self, locks):
"""
Expand Down Expand Up @@ -907,6 +915,8 @@ def add(self, skelType: SkelType, node: db.Key | int | str | None = None, *args,
skel["size"] = blob.size
skel["parentrepo"] = rootNode["key"] if rootNode else None
skel["weak"] = rootNode is None
skel["crc32c_hash"] = base64.b64decode(blob.crc32c).hex()
skel["md5_hash"] = base64.b64decode(blob.md5_hash).hex()

skel.toDB()

Expand Down

0 comments on commit 40d4e82

Please sign in to comment.