rar need special handling for directory entries

This commit is contained in:
"Jean-Francois Dockes ext:(%22) 2011-08-23 11:03:15 +02:00
parent 07f2ec6dbe
commit cdaeba390d

View File

@ -18,7 +18,7 @@
# Free Software Foundation, Inc., # Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
import rclexecm import rclexecm
try: try:
from rarfile import RarFile from rarfile import RarFile
@ -38,12 +38,27 @@ class RarExtractor:
def extractone(self, ipath): def extractone(self, ipath):
#self.em.rclog("extractone: [%s]" % ipath) #self.em.rclog("extractone: [%s]" % ipath)
docdata = "" docdata = ""
isdir = False
try: try:
docdata = self.rar.read(ipath) rarinfo = self.rar.getinfo(ipath)
ok = True isdir = rarinfo.isdir()
except Exception, err: except Exception, err:
# self.em.rclog("extractone: failed: [%s]" % err) self.em.rclog("extractone: getinfo failed: [%s]" % err)
ok = False return (True, docdata, ipath, false)
if not isdir:
try:
docdata = self.rar.read(ipath)
ok = True
except Exception, err:
self.em.rclog("extractone: failed: [%s]" % err)
ok = False
else:
docdata = ""
ok = True
self.em.setmimetype("application/x-fsdirectory")
iseof = rclexecm.RclExecM.noteof iseof = rclexecm.RclExecM.noteof
if self.currentindex >= len(self.rar.namelist()) -1: if self.currentindex >= len(self.rar.namelist()) -1:
iseof = rclexecm.RclExecM.eofnext iseof = rclexecm.RclExecM.eofnext