testleri geç
This commit is contained in:
+6
-4
@@ -181,6 +181,8 @@ class MyZipFile(zipfile.ZipFile):
|
|||||||
total_read = 0
|
total_read = 0
|
||||||
crc = None
|
crc = None
|
||||||
while total_read < zinfo.compress_size:
|
while total_read < zinfo.compress_size:
|
||||||
|
if zinfo.compress_size - total_read < block_size:
|
||||||
|
block_size = zinfo.compress_size - total_read
|
||||||
buff = self.fp.read(block_size)
|
buff = self.fp.read(block_size)
|
||||||
destfile.write(buff)
|
destfile.write(buff)
|
||||||
total_read += (block_size)
|
total_read += (block_size)
|
||||||
@@ -190,7 +192,7 @@ class MyZipFile(zipfile.ZipFile):
|
|||||||
crc = binascii.crc32(buff)
|
crc = binascii.crc32(buff)
|
||||||
destfile.close()
|
destfile.close()
|
||||||
self.fp.seek(filepos, 0)
|
self.fp.seek(filepos, 0)
|
||||||
if crc != zinfo.CRC:
|
if crc and crc != zinfo.CRC:
|
||||||
raise zipfile.BadZipfile, "Bad CRC-32 for file %s" % name
|
raise zipfile.BadZipfile, "Bad CRC-32 for file %s" % name
|
||||||
return
|
return
|
||||||
elif zinfo.compress_type != zipfile.ZIP_DEFLATED:
|
elif zinfo.compress_type != zipfile.ZIP_DEFLATED:
|
||||||
@@ -207,8 +209,8 @@ class MyZipFile(zipfile.ZipFile):
|
|||||||
total_read = 0
|
total_read = 0
|
||||||
crc = None
|
crc = None
|
||||||
while total_read < zinfo.compress_size:
|
while total_read < zinfo.compress_size:
|
||||||
if name == "install.tar.lzma":
|
if zinfo.compress_size - total_read < block_size:
|
||||||
print "blalalall", zinfo.compress_size
|
block_size = zinfo.compress_size - total_read
|
||||||
buff = self.fp.read(block_size)
|
buff = self.fp.read(block_size)
|
||||||
dcbuff = dc.decompress(dc.unconsumed_tail + buff)
|
dcbuff = dc.decompress(dc.unconsumed_tail + buff)
|
||||||
destfile.write(dcbuff)
|
destfile.write(dcbuff)
|
||||||
@@ -227,7 +229,7 @@ class MyZipFile(zipfile.ZipFile):
|
|||||||
crc = binascii.crc32(ex)
|
crc = binascii.crc32(ex)
|
||||||
destfile.write(ex)
|
destfile.write(ex)
|
||||||
|
|
||||||
if crc != zinfo.CRC:
|
if crc and crc != zinfo.CRC:
|
||||||
raise zipfile.BadZipfile, "Bad CRC-32 for file %s" % name
|
raise zipfile.BadZipfile, "Bad CRC-32 for file %s" % name
|
||||||
|
|
||||||
destfile.close()
|
destfile.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user