1
0
Fork 0
mirror of https://github.com/Findus23/PaperLibrary-cli.git synced 2024-09-20 17:03:46 +02:00

speed up hash

This commit is contained in:
Lukas Winkler 2024-04-17 16:57:07 +02:00
parent f1c7b5e29e
commit 883e9648d7
Signed by: lukas
GPG key ID: 54DE4D798D244853

View file

@ -119,6 +119,10 @@ def download_file(api: PaperLibraryAPI, url: str, target_file: Path):
def hash_file(file: Path, buffer_size=65536) -> str:
try:
with file.open("rb") as f:
return hashlib.file_digest(f, "sha256").hexdigest()
except AttributeError:
sha256 = hashlib.sha256()
with file.open("rb") as f:
while True: