Input handlers: more closing to help with windows temp files

This commit is contained in:
Jean-Francois Dockes
2019-07-21 10:03:03 +02:00
parent a1daa8de55
commit af664e7768
4 changed files with 42 additions and 6 deletions
+10 -1
View File
@@ -13,15 +13,20 @@ class WarExtractor:
def extractone(self, tarinfo):
docdata = ""
iseof = rclexecm.RclExecM.noteof
try:
member = self.tar.extractfile(tarinfo)
docdata = member.read()
ok = True
except Exception as err:
self.em.rclog("extractone: failed: [%s]" % err)
iseof = rclexecm.RclExecM.eofnow
ok = False
return (ok, docdata, tarinfo.name, rclexecm.RclExecM.noteof)
return (ok, docdata, tarinfo.name, iseof)
def closefile():
self.tar = None
###### File type handler api, used by rclexecm ---------->
def openfile(self, params):
self.currentindex = -1
@@ -50,9 +55,13 @@ class WarExtractor:
tarinfo = self.tar.next()
if tarinfo is None:
#self.em.rclog("getnext: EOF hit")
self.closefile()
return (False, "", "", rclexecm.RclExecM.eofnow)
else:
ret = self.extractone(tarinfo)
if ret[3] == rclexecm.RclExecM.eofnext or \
ret[3] == rclexecm.RclExecM.eofnow:
self.closefile()
return ret
# Main program: create protocol handler and extractor and run them