feat(analyzer): move compute_md5 to shared library
This commit is contained in:
parent
c0bddf83a8
commit
be9f36dbdc
4 changed files with 29 additions and 21 deletions
17
shared/libretime_shared/files.py
Normal file
17
shared/libretime_shared/files.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def compute_md5(filepath: Path) -> str:
|
||||
"""
|
||||
Compute a file md5sum.
|
||||
"""
|
||||
with filepath.open("rb") as file:
|
||||
buffer = hashlib.md5() # nosec
|
||||
while True:
|
||||
blob = file.read(8192)
|
||||
if not blob:
|
||||
break
|
||||
buffer.update(blob)
|
||||
|
||||
return buffer.hexdigest()
|
Loading…
Add table
Add a link
Reference in a new issue