From c4052c0f1d55052daaf0707050479e2a4ef6f1df Mon Sep 17 00:00:00 2001 From: 64Core Date: Sat, 4 Jun 2022 13:23:31 -0500 Subject: [PATCH] Better handling of verify logic in do_download --- itchiodl/game.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/itchiodl/game.py b/itchiodl/game.py index f1215cb..c9ff3c0 100644 --- a/itchiodl/game.py +++ b/itchiodl/game.py @@ -121,8 +121,8 @@ class Game: if os.path.exists(f"{path}/{file}"): print(f"File Already Exists! {file}") - if os.path.exists(f"{path}/{file}.md5"): - if self.verify: + if self.verify: + if os.path.exists(f"{path}/{file}.md5"): with open(f"{path}/{file}.md5", "r") as f: md5 = f.read().strip() @@ -131,8 +131,7 @@ class Game: return print(f"MD5 Mismatch! {file}") - else: - if self.verify: + else: md5 = itchiodl.utils.md5sum(f"{path}/{file}") if md5 == d["md5_hash"]: print(f"Skipping {self.name} - {file}") @@ -147,13 +146,16 @@ class Game: os.remove(f"{path}/{file}") return - if not os.path.exists(f"{path}/old"): - os.mkdir(f"{path}/old") + if not os.path.exists(f"{path}/old"): + os.mkdir(f"{path}/old") - print(f"Moving {file} to old/") - timestamp = datetime.datetime.now().strftime("%Y-%m-%d") - print(timestamp) - shutil.move(f"{path}/{file}", f"{path}/old/{timestamp}-{file}") + print(f"Moving {file} to old/") + timestamp = datetime.datetime.now().strftime("%Y-%m-%d") + print(timestamp) + shutil.move(f"{path}/{file}", f"{path}/old/{timestamp}-{file}") + else: + print(f"Skipping {self.name} - {file}") + return # Get UUID r = requests.post(