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

Commits:
5a896579 by Philipp Hörist at 2017-07-10T16:25:26+02:00
Commit to DB before shutdown

Because some operations use the _timeout_commit() it happens that a timeout
is active while we shutdown.

This makes sure everything is commited before shutdown.

- - - - -
aeb64a51 by Philipp Hörist at 2017-07-10T16:39:27+02:00
Use correct history date on muc join

Example:
If we receive a message the last message date is now.
If we restart Gajim and join the MUC again, `time.time() - timeout`
will be most likly smaller then when we received the last message
If the timeout is an hour, this would mean that many messages are requested
from the archive which we already received.

So we always want the most current timestamp (MAX).

- - - - -


3 changed files:

- gajim/common/connection.py
- gajim/common/logger.py
- gajim/roster_window.py


Changes:

=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -2598,7 +2598,7 @@ class Connection(CommonConnection, ConnectionHandlers):
                 if last_date == 0:
                     last_date = time.time() - timeout
                 elif not rejoin:
-                    last_date = min(last_date, time.time() - timeout)
+                    last_date = max(last_date, time.time() - timeout)
                 last_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(
                     last_date))
                 tags['since'] = last_date


=====================================
gajim/common/logger.py
=====================================
--- a/gajim/common/logger.py
+++ b/gajim/common/logger.py
@@ -168,7 +168,7 @@ class Logger:
         self.open_db()
         self.get_jids_already_in_db()
 
-    def _really_commit(self):
+    def commit(self):
         try:
             self.con.commit()
         except sqlite.OperationalError as e:
@@ -179,7 +179,7 @@ class Logger:
     def _timeout_commit(self):
         if self.commit_timout_id:
             return
-        self.commit_timout_id = GLib.timeout_add(500, self._really_commit)
+        self.commit_timout_id = GLib.timeout_add(500, self.commit)
 
     def simple_commit(self, sql_to_commit):
         """


=====================================
gajim/roster_window.py
=====================================
--- a/gajim/roster_window.py
+++ b/gajim/roster_window.py
@@ -2469,6 +2469,9 @@ class RosterWindow:
             gajim.interface.hide_systray()
         self.save_done = True
 
+        # Commit any outstanding SQL transactions
+        gajim.logger.commit()
+
     def quit_gtkgui_interface(self):
         """
         When we quit the gtk interface - exit gtk



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

Reply via email to