mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-11 20:22:39 -03:00
Make Web.set_file_info return False on cancel
This commit is contained in:
parent
72f76bf659
commit
c52c846227
1 changed files with 8 additions and 4 deletions
|
@ -544,13 +544,15 @@ class Web(object):
|
||||||
# Canceling early?
|
# Canceling early?
|
||||||
if self.cancel_compression:
|
if self.cancel_compression:
|
||||||
self.zip_writer.close()
|
self.zip_writer.close()
|
||||||
return
|
return False
|
||||||
|
|
||||||
for info in self.file_info['dirs']:
|
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_writer.close()
|
||||||
self.zip_filesize = os.path.getsize(self.zip_filename)
|
self.zip_filesize = os.path.getsize(self.zip_filename)
|
||||||
|
return True
|
||||||
|
|
||||||
def _safe_select_jinja_autoescape(self, filename):
|
def _safe_select_jinja_autoescape(self, filename):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
|
@ -692,8 +694,8 @@ class ZipWriter(object):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
# Canceling early?
|
# Canceling early?
|
||||||
if self.cancel_compression:
|
if self.cancel_compression:
|
||||||
return
|
return False
|
||||||
|
|
||||||
full_filename = os.path.join(dirpath, f)
|
full_filename = os.path.join(dirpath, f)
|
||||||
if not os.path.islink(full_filename):
|
if not os.path.islink(full_filename):
|
||||||
arc_filename = full_filename[len(dir_to_strip):]
|
arc_filename = full_filename[len(dir_to_strip):]
|
||||||
|
@ -701,6 +703,8 @@ class ZipWriter(object):
|
||||||
self._size += os.path.getsize(full_filename)
|
self._size += os.path.getsize(full_filename)
|
||||||
self.processed_size_callback(self._size)
|
self.processed_size_callback(self._size)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
Close the zip archive.
|
Close the zip archive.
|
||||||
|
|
Loading…
Reference in a new issue