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:
parent
f1c7b5e29e
commit
883e9648d7
1 changed files with 12 additions and 8 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue