Mercurial > libervia-backend
changeset 2901:f6b0088ce247
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 10 Apr 2019 21:04:41 +0200 (2019-04-10) |
parents | 93dfbeb41da8 |
children | 9241f9d1f9e5 |
files | sat/core/xmpp.py |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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: