mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
refactor: one digest and one lock name for probes
This commit is contained in:
1 parent
4ea44a027e
commit
cacd290d2e
10 files changed
+43
-76
No files matched your search
@@ -85,6 +85,15 @@ def _compute_hashes(filepath: str | Path, algos: frozenset[str]) -> dict[str, st
|
||||
result["adler32"] = format(adler & 0xFFFFFFFF, "08x")
|
||||
return result
|
||||
|
||||
def file_digest(path: Path, algorithm: str = "sha1") -> str:
|
||||
"""The hex digest of a file by any hashlib algorithm, read again each call."""
|
||||
digest = hashlib.new(algorithm)
|
||||
with path.open("rb") as handle:
|
||||
for chunk in iter(lambda: handle.read(1 << 20), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def md5sum(source: str | os.PathLike[str] | IO[bytes]) -> str:
|
||||
"""Compute MD5 of a file path or file-like object - matches Batocera's md5sum()."""
|
||||
h = hashlib.md5()
|
||||
|
||||
Reference in new issue
Block a user