feat(analyzer): move compute_md5 to shared library

This commit is contained in:
jo 2022-06-15 15:56:52 +02:00 committed by Kyle Robbertze
parent c0bddf83a8
commit be9f36dbdc
4 changed files with 29 additions and 21 deletions

View file

@ -1,9 +1,9 @@
import hashlib
from datetime import timedelta
from pathlib import Path
from typing import Any, Dict
import mutagen
from libretime_shared.files import compute_md5
from loguru import logger
@ -108,18 +108,3 @@ def analyze_metadata(filepath_: str, metadata: Dict[str, Any]):
continue
return metadata
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()