mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
ReceiveModeRequest should only deal with upload_ids for upload requests, not for other requests
This commit is contained in:
parent
eb3d6f2171
commit
841e47b234
@ -670,9 +670,6 @@ class ReceiveModeRequest(Request):
|
||||
super(ReceiveModeRequest, self).__init__(environ, populate_request, shallow)
|
||||
self.web = environ['web']
|
||||
|
||||
# A dictionary that maps filenames to the bytes uploaded so far
|
||||
self.progress = {}
|
||||
|
||||
# Is this a valid upload request?
|
||||
self.upload_request = False
|
||||
if self.method == 'POST':
|
||||
@ -683,7 +680,11 @@ class ReceiveModeRequest(Request):
|
||||
if self.path == '/{}/upload'.format(self.web.slug):
|
||||
self.upload_request = True
|
||||
|
||||
# If this is an upload request, create an upload_id (attach it to the request)
|
||||
if self.upload_request:
|
||||
# A dictionary that maps filenames to the bytes uploaded so far
|
||||
self.progress = {}
|
||||
|
||||
# Create an upload_id, attach it to the request
|
||||
self.upload_id = self.web.upload_count
|
||||
self.web.upload_count += 1
|
||||
|
||||
@ -697,6 +698,7 @@ class ReceiveModeRequest(Request):
|
||||
This gets called for each file that gets uploaded, and returns an file-like
|
||||
writable stream.
|
||||
"""
|
||||
if self.upload_request:
|
||||
# Tell the GUI about the new file upload
|
||||
self.web.add_request(Web.REQUEST_UPLOAD_NEW_FILE_STARTED, self.path, {
|
||||
'id': self.upload_id,
|
||||
@ -719,6 +721,7 @@ class ReceiveModeRequest(Request):
|
||||
When closing the request, print a newline if this was a file upload.
|
||||
"""
|
||||
super(ReceiveModeRequest, self).close()
|
||||
if self.upload_request:
|
||||
if len(self.progress) > 0:
|
||||
print('')
|
||||
|
||||
@ -726,6 +729,7 @@ class ReceiveModeRequest(Request):
|
||||
"""
|
||||
Keep track of the bytes uploaded so far for all files.
|
||||
"""
|
||||
if self.upload_request:
|
||||
self.progress[filename]['uploaded_bytes'] += length
|
||||
uploaded = self.web.common.human_readable_filesize(self.progress[filename]['uploaded_bytes'])
|
||||
total = self.web.common.human_readable_filesize(self.progress[filename]['total_bytes'])
|
||||
|
Loading…
Reference in New Issue
Block a user