Skip to content

Commit

Permalink
Handling exception, root cause unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
andresriancho committed Jun 10, 2019
1 parent 5d0b89f commit bd0ea21
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion w3af/core/data/db/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,16 @@ def _load_from_zip(self, _id):
raise TraceReadException('No zip file contains %s' % _id)

def _load_from_zip_file(self, _id, zip_file):
_zip = zipfile.ZipFile(os.path.join(self.get_session_dir(), zip_file))
try:
_zip = zipfile.ZipFile(os.path.join(self.get_session_dir(), zip_file))
except zipfile.BadZipfile:
# We get here when the zip file has an invalid format
#
# This is most likely because one thread is writing to disk and
# another is trying to read from it
msg = 'Zip file %s has an invalid format'
args = (zip_file,)
raise TraceReadException(msg % args)

try:
serialized_req_res = _zip.read('%s.%s' % (_id, self._EXTENSION))
Expand Down

0 comments on commit bd0ea21

Please sign in to comment.