Bug 1258574 - Allow JARReader to read data already in memory; r=glandium
authorGregory Szorc <gps@mozilla.com>
Mon, 21 Mar 2016 16:36:22 -0700
changeset 289727 36595ad87d9cc2dc85b2f4eaebeed57bdd203544
parent 289726 cdf79a0b9a3b9c26741e67df444ce000a0b8baa4
child 289728 fad8fe6c7c9005466b61bc6e306b0fe718acaf15
push id30108
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 11:14:31 +0000
treeherdermozilla-central@ea6298e1b4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1258574
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1258574 - Allow JARReader to read data already in memory; r=glandium This will be needed to teach artifact builds to extract files from omni.ja files whose content is loaded into memory (from a tar archive). MozReview-Commit-ID: LH2HkKx5Zj3
python/mozbuild/mozpack/mozjar.py
--- a/python/mozbuild/mozpack/mozjar.py
+++ b/python/mozbuild/mozpack/mozjar.py
@@ -327,24 +327,24 @@ class JarFileReader(object):
         return self._uncompressed_data
 
 
 class JarReader(object):
     '''
     Class with methods to read Jar files. Can open standard jar files as well
     as Mozilla jar files (see further details in the JarWriter documentation).
     '''
-    def __init__(self, file=None, fileobj=None):
+    def __init__(self, file=None, fileobj=None, data=None):
         '''
         Opens the given file as a Jar archive. Use the given file-like object
         if one is given instead of opening the given file name.
         '''
         if fileobj:
             data = fileobj.read()
-        else:
+        elif file:
             data = open(file, 'rb').read()
         self._data = memoryview(data)
         # The End of Central Directory Record has a variable size because of
         # comments it may contain, so scan for it from the end of the file.
         offset = -CDIR_END_SIZE
         while True:
             signature = JarStruct.get_data('uint32', self._data[offset:])[0]
             if signature == JarCdirEnd.MAGIC: