From aa147792e64bcd8d2fe10447beced8666264bb39 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Sun, 26 Jun 2022 01:56:14 +0700 Subject: [PATCH] fix: calculate_md5 will return "" for nonexistent files --- worthless/installer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worthless/installer.py b/worthless/installer.py index 17213ba..358c7ec 100644 --- a/worthless/installer.py +++ b/worthless/installer.py @@ -492,7 +492,10 @@ class Installer: contents = await pkg_version.read_text() 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() while chunk := await f.read(self._download_chunk): file_hash.update(chunk)