work on fixing weird upload issues
parent
fbcb95be9e
commit
57225f57f0
|
@ -90,6 +90,11 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'):
|
|||
url = f'http://{peer}/upload'
|
||||
try:
|
||||
data = block.Block(bl).getRaw()
|
||||
if not data:
|
||||
logger.warn(
|
||||
f"Couldn't data for block in upload list {bl}",
|
||||
terminal=True)
|
||||
raise onionrexceptions.NoDataAvailable
|
||||
except onionrexceptions.NoDataAvailable:
|
||||
finishedUploads.append(bl)
|
||||
break
|
||||
|
|
|
@ -35,8 +35,11 @@ def accept_upload(request):
|
|||
"""Accept uploaded blocks to our public Onionr protocol API server"""
|
||||
resp = 'failure'
|
||||
data = request.get_data()
|
||||
b_hash = ''
|
||||
if sys.getsizeof(data) < 100000000:
|
||||
data_size = sys.getsizeof(data)
|
||||
print(data)
|
||||
if data_size < 30:
|
||||
resp = 'size'
|
||||
elif data_size < 100000000:
|
||||
try:
|
||||
b_hash = blockimporter.import_block_from_data(data)
|
||||
if b_hash:
|
||||
|
@ -70,6 +73,10 @@ def accept_upload(request):
|
|||
resp = 'failure'
|
||||
if resp == 'failure':
|
||||
abort(400)
|
||||
elif resp == 'size':
|
||||
resp = Response(resp, 400)
|
||||
logger.warn(
|
||||
f'Error importing uploaded block, invalid size {b_hash}')
|
||||
elif resp == 'proof':
|
||||
resp = Response(resp, 400)
|
||||
logger.warn(
|
||||
|
|
|
@ -6,6 +6,7 @@ from json import JSONDecodeError
|
|||
import ujson as json
|
||||
|
||||
from onionrutils import bytesconverter
|
||||
import logger
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -40,6 +41,9 @@ def get_block_metadata_from_data(block_data):
|
|||
metadata = json.loads(bytesconverter.bytes_to_str(block_data[:block_data.find(b'\n')]))
|
||||
except JSONDecodeError:
|
||||
pass
|
||||
except ValueError:
|
||||
logger.warn("Could not get metadata from:", terminal=True)
|
||||
logger.warn(block_data, terminal=True)
|
||||
else:
|
||||
data = block_data[block_data.find(b'\n'):]
|
||||
|
||||
|
|
Loading…
Reference in New Issue