mirror of
https://github.com/onionshare/onionshare.git
synced 2025-08-25 06:29:54 -04:00
Fix the discrepancy between SendBaseModeWeb and Web objects' separate cur_history_id attibutes, ensuring that when we call web.error404() we send a new history_id integer for communicating back to the frontend. Add tests for this
This commit is contained in:
parent
4a4437394d
commit
2c87ea55ff
9 changed files with 92 additions and 15 deletions
|
@ -29,6 +29,9 @@ class SendBaseModeWeb:
|
|||
# one download at a time.
|
||||
self.download_in_progress = False
|
||||
|
||||
# This tracks the history id
|
||||
self.cur_history_id = 0
|
||||
|
||||
self.define_routes()
|
||||
self.init()
|
||||
|
||||
|
@ -264,4 +267,4 @@ class SendBaseModeWeb:
|
|||
"""
|
||||
Inherited class will implement this.
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -207,11 +207,15 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
if self.download_individual_files:
|
||||
return self.stream_individual_file(filesystem_path)
|
||||
else:
|
||||
return self.web.error404()
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
return self.web.error404(history_id)
|
||||
|
||||
# If it's not a directory or file, throw a 404
|
||||
else:
|
||||
return self.web.error404()
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
return self.web.error404(history_id)
|
||||
else:
|
||||
# Special case loading /
|
||||
|
||||
|
@ -223,7 +227,9 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
|
||||
else:
|
||||
# If the path isn't found, throw a 404
|
||||
return self.web.error404()
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
return self.web.error404(history_id)
|
||||
|
||||
def build_zipfile_list(self, filenames, processed_size_callback=None):
|
||||
self.common.log("ShareModeWeb", "build_zipfile_list")
|
||||
|
|
|
@ -63,9 +63,6 @@ class Web:
|
|||
self.auth = HTTPBasicAuth()
|
||||
self.auth.error_handler(self.error401)
|
||||
|
||||
# This tracks the history id
|
||||
self.cur_history_id = 0
|
||||
|
||||
# Verbose mode?
|
||||
if self.common.verbose:
|
||||
self.verbose_mode()
|
||||
|
@ -204,9 +201,7 @@ class Web:
|
|||
r = make_response(render_template('403.html', static_url_path=self.static_url_path), 403)
|
||||
return self.add_security_headers(r)
|
||||
|
||||
def error404(self):
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
def error404(self, history_id):
|
||||
self.add_request(self.REQUEST_INDIVIDUAL_FILE_STARTED, '{}'.format(request.path), {
|
||||
'id': history_id,
|
||||
'status_code': 404
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue