Fixed encrypted uploads

master
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,6 +67,7 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'):
session = session_manager.add_session(bl) session = session_manager.add_session(bl)
for _ in range(min(len(kv.get('onlinePeers')), 6)): for _ in range(min(len(kv.get('onlinePeers')), 6)):
try: try:
if not block.Block(bl).isEncrypted():
peer = onlinepeers.pick_online_peer(kv) peer = onlinepeers.pick_online_peer(kv)
if peer in kv.get('plaintextDisabledPeers'): if peer in kv.get('plaintextDisabledPeers'):
logger.info(f"Cannot upload plaintext block to peer that denies it {peer}") # noqa logger.info(f"Cannot upload plaintext block to peer that denies it {peer}") # noqa

View File

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

View File

@ -104,7 +104,7 @@ def getData(bHash):
fileLocation = '%s/%s%s' % ( fileLocation = '%s/%s%s' % (
block_data_location, block_data_location,
bHash, BLOCK_EXPORT_FILE_EXT) 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): if os.path.exists(fileLocation):
with open(fileLocation, 'rb') as block: with open(fileLocation, 'rb') as block:
ret_data = block.read() ret_data = block.read()
@ -112,5 +112,5 @@ def getData(bHash):
ret_data = _dbFetch(bHash) ret_data = _dbFetch(bHash)
if ret_data is None: if ret_data is None:
raise onionrexceptions.NoDataAvailable(not_found_msg + str(bHash)) raise onionrexceptions.NoDataAvailable(not_found_msg)
return ret_data return ret_data