fix: calculate_md5 will return "" for nonexistent files
This commit is contained in:
parent
23980276ee
commit
aa147792e6
@ -492,7 +492,10 @@ class Installer:
|
|||||||
contents = await pkg_version.read_text()
|
contents = await pkg_version.read_text()
|
||||||
|
|
||||||
async def calculate_md5(file_to_calculate):
|
async def calculate_md5(file_to_calculate):
|
||||||
async with AsyncPath(file_to_calculate).open("rb") as f:
|
file_to_calculate = AsyncPath(file_to_calculate)
|
||||||
|
if not await file_to_calculate.exists():
|
||||||
|
return ""
|
||||||
|
async with file_to_calculate.open("rb") as f:
|
||||||
file_hash = hashlib.md5()
|
file_hash = hashlib.md5()
|
||||||
while chunk := await f.read(self._download_chunk):
|
while chunk := await f.read(self._download_chunk):
|
||||||
file_hash.update(chunk)
|
file_hash.update(chunk)
|
||||||
|
Loading…
Reference in New Issue
Block a user