diff --git a/tools/mkzip.py b/tools/mkzip.py index c125a5a2..07f28577 100644 --- a/tools/mkzip.py +++ b/tools/mkzip.py @@ -5,6 +5,14 @@ import os import os.path import zipfile from shutil import copyfile +import hashlib + +def md5(fname): + hash_md5 = hashlib.md5() + with open(fname, "rb") as f: + for chunk in iter(lambda: f.read(4096), b""): + hash_md5.update(chunk) + return hash_md5.hexdigest() if len(sys.argv) < 3: print('usage: mkzip ') @@ -21,9 +29,11 @@ with open(sys.argv[1], 'r') as f: for (fname, aname) in lst: path = os.path.join(sys.argv[2], aname) - if not os.path.exists(path): + old_md5 = md5(fname); + new_md5 = md5(path); + if not os.path.exists(path) or old_md5 != new_md5: os.makedirs(os.path.dirname(path), exist_ok=True) copyfile(fname, path) print("Copying: " + path) else: - print("Skipping: " + path) + print("Skipping: " + path + " - MD5: "+md5(fname))