comparison sat/memory/memory.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents 98d1f34ce5b9
children 8b36e5c3f28f
comparison
equal deleted inserted replaced
3039:a1bc34f90fa5 3040:fee60f17ebac
558 558
559 d = self.params.createProfile(name, component) 559 d = self.params.createProfile(name, component)
560 560
561 def initPersonalKey(__): 561 def initPersonalKey(__):
562 # be sure to call this after checking that the profile doesn't exist yet 562 # be sure to call this after checking that the profile doesn't exist yet
563
564 # generated once for all and saved in a PersistentDict
563 personal_key = BlockCipher.getRandomKey( 565 personal_key = BlockCipher.getRandomKey(
564 base64=True 566 base64=True
565 ) # generated once for all and saved in a PersistentDict 567 ).decode('utf-8')
566 self.auth_sessions.newSession( 568 self.auth_sessions.newSession(
567 {C.MEMORY_CRYPTO_KEY: personal_key}, profile=name 569 {C.MEMORY_CRYPTO_KEY: personal_key}, profile=name
568 ) # will be encrypted by setParam 570 ) # will be encrypted by setParam
569 571
570 def startFakeSession(__): 572 def startFakeSession(__):
1258 while True: 1260 while True:
1259 self.checkFilePermission(current, peer_jid, perms_to_check) 1261 self.checkFilePermission(current, peer_jid, perms_to_check)
1260 parent = current["parent"] 1262 parent = current["parent"]
1261 if not parent: 1263 if not parent:
1262 break 1264 break
1263 files_data = yield self.getFile( 1265 files_data = yield self.getFiles(
1264 self, client, peer_jid=None, file_id=parent, perms_to_check=None 1266 client, peer_jid=None, file_id=parent, perms_to_check=None
1265 ) 1267 )
1266 try: 1268 try:
1267 current = files_data[0] 1269 current = files_data[0]
1268 except IndexError: 1270 except IndexError:
1269 raise exceptions.DataError("Missing parent") 1271 raise exceptions.DataError("Missing parent")