Since you are also working on separating archives, I have a script you may need it sometimes. It collects only different resources compared with the old graph.json
.
One thing I’m noticing is that there are some resources that have been changed hexDigest
but I haven’t changed its content.
make_update.py
import os
import sys
import json
import shutil
current_dir = os.path.dirname(os.path.realpath(__file__))
extract_dir = os.path.join(current_dir, 'tmp1')
working_dir = os.path.join(current_dir, 'tmp2')
if __name__ == '__main__':
# requirement: python 3
# usage: python make_update.py [old_graph_filename] [new_graph_filename] [source_zip]
# example: python make_update.py v10.graph.json v11.graph.json v11_full.zip
# output: update.zip (contains only new & changed files)
old_graph_filename = sys.argv[1]
new_graph_filename = sys.argv[2]
source_zip = sys.argv[3]
with open(old_graph_filename) as user_file:
contents = json.loads(user_file.read())
old_graph = {}
for el in contents:
old_graph[el['hexDigest']] = el
with open(new_graph_filename) as user_file:
contents = json.loads(user_file.read())
new_graph = {}
for el in contents:
new_graph[el['hexDigest']] = el
changed_list = []
for key in new_graph:
if key not in old_graph and new_graph[key]['isInMainBundle'] == False:
changed_list.append(new_graph[key])
if len(changed_list) > 0:
shutil.rmtree(extract_dir, ignore_errors=True)
shutil.rmtree(working_dir, ignore_errors=True)
os.makedirs(working_dir)
shutil.unpack_archive(source_zip, extract_dir)
for el in changed_list:
print(el['hexDigest'] + ' - ' + el['path'])
shutil.copy(extract_dir + '/' + el['hexDigest'], working_dir)
shutil.copy(extract_dir + '/liveupdate.game.dmanifest', working_dir)
shutil.make_archive('update', 'zip', working_dir)
shutil.rmtree(extract_dir)
shutil.rmtree(working_dir)