From 93d176badca5d72c50b0133394dc977c05f2ef89 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 3 Dec 2020 06:12:06 +0000 Subject: [PATCH] fix upload.py logging b_hash define --- src/httpapi/miscpublicapi/upload.py | 14 +++++++++----- tests/runtime-result.txt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/httpapi/miscpublicapi/upload.py b/src/httpapi/miscpublicapi/upload.py index de3f7243..9e57f1e4 100755 --- a/src/httpapi/miscpublicapi/upload.py +++ b/src/httpapi/miscpublicapi/upload.py @@ -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 diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index 58067c86..3fe82038 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1606103134 \ No newline at end of file +1606975647 \ No newline at end of file