mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 11:28:51 -06:00
refactor: share the git blob check of downloads
This commit is contained in:
1 parent
8d58a9edfd
commit
fd0f6c7798
6 files changed
+55
-48
No files matched your search
@@ -112,6 +112,14 @@ def file_digest(path: Path, algorithm: str = "sha1") -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def git_blob_sha(data: bytes) -> str:
|
||||
"""The sha git gives a blob, so a cached file can be checked against a
|
||||
repository listing without any other state."""
|
||||
digest = hashlib.sha1(f"blob {len(data)}\0".encode())
|
||||
digest.update(data)
|
||||
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()."""
|
||||
if isinstance(source, (str, os.PathLike)):
|
||||
|
||||
Reference in new issue
Block a user