fix upload.py logging b_hash define

master
Kevin Froman 2020-12-03 06:12:06 +00:00
parent 968f468027
commit 93d176badc
2 changed files with 10 additions and 6 deletions

View File

@ -36,7 +36,7 @@ def accept_upload(request):
resp = 'failure' resp = 'failure'
data = request.get_data() data = request.get_data()
data_size = sys.getsizeof(data) data_size = sys.getsizeof(data)
b_hash = None
if data_size < 30: if data_size < 30:
resp = 'size' resp = 'size'
elif data_size < 100000000: elif data_size < 100000000:
@ -69,11 +69,11 @@ def accept_upload(request):
except onionrexceptions.DataExists: except onionrexceptions.DataExists:
resp = 'exists' resp = 'exists'
except onionrexceptions.PlaintextNotSupported: except onionrexceptions.PlaintextNotSupported:
logger.debug("attempted plaintext upload to us: {b_hash}") logger.debug(f"attempted plaintext upload to us: {b_hash}")
resp = 'failure' resp = 'failure'
except onionrexceptions.InvalidMetadata: except onionrexceptions.InvalidMetadata:
logger.debug( logger.debug(
'uploaded block {b_hash} has invalid metadata') f'uploaded block {b_hash} has invalid metadata')
resp = 'failure' resp = 'failure'
if resp == 'failure': if resp == 'failure':
abort(400) abort(400)
@ -83,8 +83,12 @@ def accept_upload(request):
f'Error importing uploaded block, invalid size {b_hash}') f'Error importing uploaded block, invalid size {b_hash}')
elif resp == 'proof': elif resp == 'proof':
resp = Response(resp, 400) resp = Response(resp, 400)
if b_hash:
logger.warn( logger.warn(
f'Error importing uploaded block, invalid proof {b_hash}') f'Error importing uploaded block, invalid proof {b_hash}')
else:
logger.warn(
'Error importing uploaded block, invalid proof')
else: else:
resp = Response(resp) resp = Response(resp)
return resp return resp

View File

@ -1 +1 @@
1606103134 1606975647