diff --git a/script/release/uploaders/upload.py b/script/release/uploaders/upload.py index e37623bb5e..670c2e890f 100755 --- a/script/release/uploaders/upload.py +++ b/script/release/uploaders/upload.py @@ -6,9 +6,11 @@ import datetime import errno import hashlib import json +import mmap import os import shutil import subprocess +from struct import Struct import sys import tempfile @@ -164,9 +166,65 @@ def get_electron_build_version(): return subprocess.check_output([electron, '--version']).strip() +class NonZipFileError(ValueError): + """Raised when a given file does not appear to be a zip""" + + +def zero_zip_date_time(fname): + """ Wrap strip-zip zero_zip_date_time within a file opening operation """ + try: + zip = open(fname, 'r+b') + _zero_zip_date_time(zip) + except: + raise NonZipFileError(fname) + finally: + zip.close() + + +def _zero_zip_date_time(zip_): + """ Code under MIT from https://github.com/Code0x58/python-stripzip/blob/f1980fcfc55cb6ee1f83a2f72244dd38b3b649f4/stripzip.py """ + archive_size = os.fstat(zip_.fileno()).st_size + + signature_struct = Struct("