skip very big files (50M) in zip tar and rar extractors
This commit is contained in:
parent
2bb14cc6ff
commit
b321b0babb
@ -49,7 +49,12 @@ class RarExtractor:
|
|||||||
|
|
||||||
if not isdir:
|
if not isdir:
|
||||||
try:
|
try:
|
||||||
docdata = self.rar.read(ipath)
|
if rarinfo.file_size > 50 * 1024 * 1024:
|
||||||
|
self.em.rclog("extractone: entry %s size %d too big" %
|
||||||
|
(ipath, rarinfo.file_size))
|
||||||
|
docdata = ""
|
||||||
|
else:
|
||||||
|
docdata = self.rar.read(ipath)
|
||||||
ok = True
|
ok = True
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.em.rclog("extractone: failed: [%s]" % err)
|
self.em.rclog("extractone: failed: [%s]" % err)
|
||||||
|
|||||||
@ -23,7 +23,15 @@ class TarExtractor:
|
|||||||
def extractone(self, ipath):
|
def extractone(self, ipath):
|
||||||
docdata = ""
|
docdata = ""
|
||||||
try:
|
try:
|
||||||
docdata = self.tar.extractfile(ipath).read()
|
info = self.tar.getmember(ipath)
|
||||||
|
if info.size > 50 * 1024 * 1024:
|
||||||
|
# skip
|
||||||
|
docdata = ""
|
||||||
|
self.em.rclog("extractone: entry %s size %d too big" %
|
||||||
|
(ipath, info.size))
|
||||||
|
docdata = "" # raise TarError("Member too big")
|
||||||
|
else:
|
||||||
|
docdata = self.tar.extractfile(ipath).read()
|
||||||
ok = True
|
ok = True
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
ok = False
|
ok = False
|
||||||
|
|||||||
@ -45,10 +45,18 @@ class ZipExtractor:
|
|||||||
#self.em.rclog("extractone: [%s]" % ipath)
|
#self.em.rclog("extractone: [%s]" % ipath)
|
||||||
docdata = ""
|
docdata = ""
|
||||||
try:
|
try:
|
||||||
docdata = self.zip.read(ipath)
|
info = self.zip.getinfo(ipath)
|
||||||
|
# There could be a 4GB Iso in the zip. We have to set a limit
|
||||||
|
if info.file_size > 50 * 1024*1024:
|
||||||
|
self.em.rclog("extractone: entry %s size %d too big" %
|
||||||
|
(ipath, info.file_size))
|
||||||
|
docdata = ""
|
||||||
|
#raise BadZipfile()
|
||||||
|
else:
|
||||||
|
docdata = self.zip.read(ipath)
|
||||||
ok = True
|
ok = True
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
# self.em.rclog("extractone: failed: [%s]" % err)
|
self.em.rclog("extractone: failed: [%s]" % err)
|
||||||
ok = False
|
ok = False
|
||||||
iseof = rclexecm.RclExecM.noteof
|
iseof = rclexecm.RclExecM.noteof
|
||||||
if self.currentindex >= len(self.zip.namelist()) -1:
|
if self.currentindex >= len(self.zip.namelist()) -1:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user