Make Web.set_file_info return False on cancel

This commit is contained in:
Micah Lee 2018-09-18 13:42:13 -07:00
parent 72f76bf659
commit c52c846227
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -544,13 +544,15 @@ class Web(object):
# Canceling early?
if self.cancel_compression:
self.zip_writer.close()
return
return False
for info in self.file_info['dirs']:
self.zip_writer.add_dir(info['filename'])
if not self.zip_writer.add_dir(info['filename']):
return False
self.zip_writer.close()
self.zip_filesize = os.path.getsize(self.zip_filename)
return True
def _safe_select_jinja_autoescape(self, filename):
if filename is None:
@ -692,8 +694,8 @@ class ZipWriter(object):
for f in filenames:
# Canceling early?
if self.cancel_compression:
return
return False
full_filename = os.path.join(dirpath, f)
if not os.path.islink(full_filename):
arc_filename = full_filename[len(dir_to_strip):]
@ -701,6 +703,8 @@ class ZipWriter(object):
self._size += os.path.getsize(full_filename)
self.processed_size_callback(self._size)
return True
def close(self):
"""
Close the zip archive.