slave remembers previous modlist

This commit is contained in:
iou1name 2019-06-15 14:39:21 -04:00
parent e3df6b4276
commit 6ec11def3e

View File

@ -15,7 +15,11 @@ def sync(delete=False):
""" """
remote_mods =urllib.request.urlopen(config_slave.remote_addr+'/get').read() remote_mods =urllib.request.urlopen(config_slave.remote_addr+'/get').read()
remote_mods = json.loads(remote_mods) remote_mods = json.loads(remote_mods)
local_mods = os.listdir('mods') if os.path.isfile('modlist.json'):
with open('modlist.json', 'r') as file:
local_mods = json.loads(file.read())
else:
local_mods = os.listdir('mods')
local_mods_del = [mod for mod in local_mods if mod not in remote_mods] local_mods_del = [mod for mod in local_mods if mod not in remote_mods]
remote_mods_get = [mod for mod in remote_mods if mod not in local_mods] remote_mods_get = [mod for mod in remote_mods if mod not in local_mods]
@ -35,6 +39,8 @@ def sync(delete=False):
with open(os.path.join('mods', mod), 'wb') as file: with open(os.path.join('mods', mod), 'wb') as file:
file.write(data) file.write(data)
print(f"Downloaded {mod}") print(f"Downloaded {mod}")
with open('modlist.json', 'w') as file:
file.write(json.dumps(remote_mods))
print("Success!") print("Success!")
if __name__ == "__main__": if __name__ == "__main__":