Allow 404 errors to work in receive mode

This commit is contained in:
Micah Lee 2019-09-15 14:46:29 -07:00
parent 86a2b35d9d
commit 16fedabf40
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,7 @@ class ReceiveModeWeb:
self.can_upload = True
self.uploads_in_progress = []
# This tracks the history id
self.cur_history_id = 0
self.define_routes()

View File

@ -119,12 +119,23 @@ class Web:
# Create the mode web object, which defines its own routes
self.share_mode = None
self.receive_mode = None
if self.mode == 'receive':
self.website_mode = None
if self.mode == 'share':
self.share_mode = ShareModeWeb(self.common, self)
elif self.mode == 'receive':
self.receive_mode = ReceiveModeWeb(self.common, self)
elif self.mode == 'website':
self.website_mode = WebsiteModeWeb(self.common, self)
elif self.mode == 'share':
self.share_mode = ShareModeWeb(self.common, self)
def get_mode(self):
if self.mode == 'share':
return self.share_mode
elif self.mode == 'receive':
return self.receive_mode
elif self.mode == 'website':
return self.website_mode
else:
return None
def generate_static_url_path(self):
# The static URL path has a 128-bit random number in it to avoid having name
@ -166,7 +177,10 @@ class Web:
@self.app.errorhandler(404)
def not_found(e):
return self.error404()
mode = self.get_mode()
history_id = mode.cur_history_id
mode.cur_history_id += 1
return self.error404(history_id)
@self.app.route("/<password_candidate>/shutdown")
def shutdown(password_candidate):