Wrap zipfile.write(), writestr() and close()

In order to work around the zip 2GiB limit, we need to wrap the related
functions in zipfile. Calls to those functions should always be replaced
with calls to the wrappers instead.

Bug: 18015246
Change-Id: I499574cee51ec4804bc10cbefe0b17940afed918
(cherry picked from commit 2ed665a033)
This commit is contained in:
Tao Bao
2015-04-01 11:21:55 -07:00
parent 821a554c1b
commit f3282b4a7f
7 changed files with 251 additions and 76 deletions

View File

@@ -43,8 +43,9 @@ OPTIONS = common.OPTIONS
def CopyInfo(output_zip):
"""Copy the android-info.txt file from the input to the output."""
output_zip.write(os.path.join(OPTIONS.input_tmp, "OTA", "android-info.txt"),
"android-info.txt")
common.ZipWrite(
output_zip, os.path.join(OPTIONS.input_tmp, "OTA", "android-info.txt"),
"android-info.txt")
def main(argv):
@@ -133,13 +134,7 @@ def main(argv):
finally:
print "cleaning up..."
# http://b/18015246
# See common.py for context. zipfile also refers to ZIP64_LIMIT during
# close() when it writes out the central directory.
saved_zip64_limit = zipfile.ZIP64_LIMIT
zipfile.ZIP64_LIMIT = (1 << 32) - 1
output_zip.close()
zipfile.ZIP64_LIMIT = saved_zip64_limit
common.ZipClose(output_zip)
shutil.rmtree(OPTIONS.input_tmp)
print "done."