mirror of
https://github.com/onionshare/onionshare.git
synced 2025-03-30 09:28:06 -04:00
Properly set the web 'done' state to True on loading the directory listing
This commit is contained in:
parent
795f63f7d6
commit
32672077d0
@ -515,7 +515,7 @@ def main(cwd=None):
|
||||
if not app.autostop_timer_thread.is_alive():
|
||||
if mode == "share":
|
||||
# If there were no attempts to download the share, or all downloads are done, we can stop
|
||||
if web.share_mode.cur_history_id == 0 or web.done:
|
||||
if not web.share_mode.download_in_progress or web.share_mode.cur_history_id == 0 or web.done:
|
||||
print("Stopped because auto-stop timer ran out")
|
||||
web.stop(app.port)
|
||||
break
|
||||
|
@ -132,6 +132,9 @@ class SendBaseModeWeb:
|
||||
self.set_file_info_custom(filenames, processed_size_callback)
|
||||
|
||||
def directory_listing(self, filenames, path="", filesystem_path=None, add_trailing_slash=False):
|
||||
"""
|
||||
Display the front page of a share or index.html-less website, listing the files/directories.
|
||||
"""
|
||||
# Tell the GUI about the directory listing
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
@ -151,6 +154,11 @@ class SendBaseModeWeb:
|
||||
|
||||
# If filesystem_path is None, this is the root directory listing
|
||||
files, dirs = self.build_directory_listing(path, filenames, filesystem_path, add_trailing_slash)
|
||||
|
||||
# Mark the request as done so we know we can close the share if in auto-stop mode.
|
||||
self.web.done = True
|
||||
|
||||
# Render and return the response.
|
||||
return self.directory_listing_template(
|
||||
path, files, dirs, breadcrumbs, breadcrumbs_leaf
|
||||
)
|
||||
@ -228,11 +236,11 @@ class SendBaseModeWeb:
|
||||
chunk_size = 102400 # 100kb
|
||||
|
||||
fp = open(file_to_download, "rb")
|
||||
done = False
|
||||
while not done:
|
||||
self.web.done = False
|
||||
while not self.web.done:
|
||||
chunk = fp.read(chunk_size)
|
||||
if chunk == b"":
|
||||
done = True
|
||||
self.web.done = True
|
||||
else:
|
||||
try:
|
||||
yield chunk
|
||||
@ -273,10 +281,10 @@ class SendBaseModeWeb:
|
||||
"filesize": filesize,
|
||||
},
|
||||
)
|
||||
done = False
|
||||
self.web.done = False
|
||||
except Exception:
|
||||
# Looks like the download was canceled
|
||||
done = True
|
||||
self.web.done = True
|
||||
|
||||
# Tell the GUI the individual file was canceled
|
||||
self.web.add_request(
|
||||
|
Loading…
x
Reference in New Issue
Block a user