# HG changeset patch # User Goffi # Date 1554923081 -7200 # Node ID f6b0088ce2476fcc7f4489200f9844e1690aeab7 # Parent 93dfbeb41da80c875d9ec5a71e46890396084473 code (xmpp): store version after roster item update + fix item removal: roster version is now stored after roster item has been added or removed. This way if something interrupting the process happens, former item update will be received and roster should be updated correctly. Roster item removal was crashing because `load()` is not used (local PersistentDict cache is then not updated, and the key to remove is missing there). The exception is now catched and ignored to avoid loading the data only to remove an item. diff -r 93dfbeb41da8 -r f6b0088ce247 sat/core/xmpp.py --- a/sat/core/xmpp.py Sun Apr 07 21:09:51 2019 +0200 +++ b/sat/core/xmpp.py Wed Apr 10 21:04:41 2019 +0200 @@ -1267,8 +1267,8 @@ if request.version is not None: # we update the cache in storage roster_cache = self.roster_cache + roster_cache[entity.full()] = item.toElement().toXml() roster_cache[ROSTER_VER_KEY] = request.version - roster_cache[entity.full()] = item.toElement().toXml() try: # update the cache for the groups the contact has been removed from left_groups = set(self._jids[entity].groups).difference(item.groups) @@ -1291,8 +1291,13 @@ if request.version is not None: # we update the cache in storage roster_cache = self.roster_cache + try: + del roster_cache[request.item.entity.full()] + except KeyError: + # because we don't use load(), cache won't have the key, but it + # will be deleted from storage anyway + pass roster_cache[ROSTER_VER_KEY] = request.version - del roster_cache[request.item.entity.full()] # we first remove item from local cache (self._groups and self._jids) try: