diff options
author | Dylan Jones <dylanjones2011@gmail.com> | 2019-01-29 21:00:39 -0500 |
---|---|---|
committer | Dylan Jones <dylanjones2011@gmail.com> | 2019-01-29 21:00:39 -0500 |
commit | ef95964d175e7dc62dec58c9b4612ad446518f42 (patch) | |
tree | 6c8ca1f1b37960d56cdc830b7fe0994def7f0fd9 /update.py | |
parent | c30078b28785902e9c95ad0d485eae8f1d3be187 (diff) | |
download | modpackman-ef95964d175e7dc62dec58c9b4612ad446518f42.tar.gz modpackman-ef95964d175e7dc62dec58c9b4612ad446518f42.zip |
hash check works?
Diffstat (limited to 'update.py')
-rwxr-xr-x | update.py | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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) |