Fixed encrypted uploads

This commit is contained in:
Kevin Froman 2020-10-10 08:41:55 +00:00
parent 0338cd64b6
commit 5baa048a4e
3 changed files with 8 additions and 6 deletions

View File

@ -67,10 +67,11 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'):
session = session_manager.add_session(bl)
for _ in range(min(len(kv.get('onlinePeers')), 6)):
try:
peer = onlinepeers.pick_online_peer(kv)
if peer in kv.get('plaintextDisabledPeers'):
logger.info(f"Cannot upload plaintext block to peer that denies it {peer}") # noqa
continue
if not block.Block(bl).isEncrypted():
peer = onlinepeers.pick_online_peer(kv)
if peer in kv.get('plaintextDisabledPeers'):
logger.info(f"Cannot upload plaintext block to peer that denies it {peer}") # noqa
continue
except onionrexceptions.OnlinePeerNeeded:
continue
try:

View File

@ -66,6 +66,7 @@ class Block:
self.signer = None
self.validSig = False
self.autoDecrypt = decrypt
self.claimedTime = None
self.update()

View File

@ -104,7 +104,7 @@ def getData(bHash):
fileLocation = '%s/%s%s' % (
block_data_location,
bHash, BLOCK_EXPORT_FILE_EXT)
not_found_msg = "Block data not found for: "
not_found_msg = "Block data not found for: " + str(bHash)
if os.path.exists(fileLocation):
with open(fileLocation, 'rb') as block:
ret_data = block.read()
@ -112,5 +112,5 @@ def getData(bHash):
ret_data = _dbFetch(bHash)
if ret_data is None:
raise onionrexceptions.NoDataAvailable(not_found_msg + str(bHash))
raise onionrexceptions.NoDataAvailable(not_found_msg)
return ret_data