Philipp Hörist pushed to branch master at gajim / gajim

Commits:
cdc2ec92 by Philipp Hörist at 2017-07-19T10:52:02+02:00
Fix not requesting roster on empty cache.db

The purpose of

`if version and not gajim.contacts.get_contacts_jid_list()`

seemed to be that when cache.db is empty (maybe it was deleted)
`gajim.contacts.get_contacts_jid_list()` should come back empty.

So on an empty roster cache, version was set to None, so that we
request in any case a new roster.

The Problem is that `gajim.contacts.get_contacts_jid_list()` is not
a good indication for an empty cache.db. On start we trigger a
`RosterReceivedEvent` which does a DB query to get the roster. Even
if that DB query comes up empty, the Event is still pushed.

In the event handler `_nec_roster_received` in roster_window.py we
add then previously open controls and our self (if the option is set)
to the roster, making `gajim.contacts.get_contacts_jid_list()` return
these contacts and hence the condition in `request_roster()` always
False.

So the version is set in the roster request, and if there is no new
version on the server, we request no new roster even though we only
have ourself and previously open controls in our roster.

As a solution for this we delete the roster version from the config
in `RosterReceivedEvent` if the DB query comes back empty, which
triggers a new roster request.

- - - - -


2 changed files:

- gajim/common/connection.py
- gajim/common/connection_handlers_events.py


Changes:

=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -2501,16 +2501,11 @@ class Connection(CommonConnection, ConnectionHandlers):
 
     def request_roster(self):
         version = None
-        features =  self.connection.Dispatcher.Stream.features
+        features = self.connection.Dispatcher.Stream.features
         if features and features.getTag('ver',
         namespace=nbxmpp.NS_ROSTER_VER):
             version = gajim.config.get_per('accounts', self.name,
                 'roster_version')
-            if version and not gajim.contacts.get_contacts_jid_list(
-            self.name):
-                gajim.config.set_per('accounts', self.name, 'roster_version',
-                    '')
-                version = None
 
         iq_id = self.connection.initRoster(version=version)
         self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, )


=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -410,6 +410,9 @@ class RosterReceivedEvent(nec.NetworkIncomingEvent):
                 'roster_version')
             self.roster = gajim.logger.get_roster(gajim.get_jid_from_account(
                 self.conn.name))
+            if not self.roster:
+                gajim.config.set_per(
+                    'accounts', self.conn.name, 'roster_version', '')
         return True
 
 class RosterSetReceivedEvent(nec.NetworkIncomingEvent):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/cdc2ec920500e50f85bc66f762b1653d7d394a8e
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to