fix upload.py logging b_hash define

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

View File

@ -1 +1 @@
1606103134
1606975647