From ef95964d175e7dc62dec58c9b4612ad446518f42 Mon Sep 17 00:00:00 2001 From: Dylan Jones Date: Tue, 29 Jan 2019 21:00:39 -0500 Subject: hash check works? --- update.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/update.py b/update.py index 40d7c21..845937e 100755 --- a/update.py +++ b/update.py @@ -21,17 +21,17 @@ def apply_updates(): with open("downloads.txt", "r") as f: for line in f: dl = line.strip().split(" ") - if len(line) > 3 and len(dl) == 2 and line[0] != '#': - dl[0] = dl[0].strip() - dl[1] = dl[1].strip() + if len(line) >= 1 and line[0] != '#': + # run strip on each element + mod = tuple(map(lambda x: x.strip(), mod)) mods.append(dl) names.add(dl[0]) for mod in mods: - if mod[0] in os.listdir(INSTALL_DIR): + if mod[0] in os.listdir(INSTALL_DIR) and hashlib.sha1(open(os.path.join(INSTALL_DIR, mod[0]), 'rb').read()).hexdigest() == mod[1]: print("Skipping " + mod[0] + ", already up to date") else: print("Installing " + mod[0] + " from " + mod[1] + "...") - download_obj = requests.get(mod[1], stream=True) + download_obj = requests.get(mod[2], stream=True) with open(os.path.join(INSTALL_DIR, mod[0]), "wb") as write_file: shutil.copyfileobj(download_obj.raw, write_file) print("Done!") @@ -50,7 +50,7 @@ def find_updates(): with open('updates.txt') as f: for line in f: mod = line.strip().split() - if len(line) > 3 and len(mod) == 2 and line[0] != '#': + if len(line) >= 1 and line[0] != '#': # run strip on each element mod = tuple(map(lambda x: x.strip(), mod)) mods.add(mod) -- cgit v1.2.3