Chromium Code Reviews| Index: build/android/gyp/util/build_utils.py |
| diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py |
| index fea8e1f79e6afbec4650a0266f01ca5eea19f6fb..4a953cdb1aa4d37da4c75ca5236bf3224c753982 100644 |
| --- a/build/android/gyp/util/build_utils.py |
| +++ b/build/android/gyp/util/build_utils.py |
| @@ -328,7 +328,13 @@ def MergeZips(output, inputs, exclude_patterns=None, path_transform=None): |
| path_transform = path_transform or (lambda p, z: p) |
| added_names = set() |
| - with zipfile.ZipFile(output, 'w') as out_zip: |
| + if isinstance(output, basestring): |
| + out_zip = zipfile.ZipFile(output, 'w') |
| + else: |
| + assert isinstance(output, zipfile.ZipFile) |
| + out_zip = output |
| + |
| + try: |
| for in_file in inputs: |
| with zipfile.ZipFile(in_file, 'r') as in_zip: |
| in_zip._expected_crc = None |
| @@ -339,8 +345,12 @@ def MergeZips(output, inputs, exclude_patterns=None, path_transform=None): |
| dst_name = path_transform(info.filename, in_file) |
| already_added = dst_name in added_names |
| if not already_added and not MatchesGlob(dst_name, exclude_patterns): |
| - AddToZipHermetic(out_zip, dst_name, data=in_zip.read(info)) |
| + AddToZipHermetic(out_zip, dst_name, data=in_zip.read(info), |
| + compress=info.compress_type != zipfile.ZIP_STORED) |
| added_names.add(dst_name) |
| + finally: |
| + if isinstance(output, basestring): |
|
michaelbai
2016/10/06 18:05:41
nit, use variable instead of checking twice?
agrieve
2016/10/06 18:17:02
Done.
|
| + out_zip.close() |
| def PrintWarning(message): |