Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
c7dbd582 by wurstsalat at 2022-05-29T13:16:01+02:00
fix: Search: Add fail-safe for incomplete JID ID tables

Fixes #10922

- - - - -


2 changed files:

- gajim/common/storage/archive.py
- gajim/gtk/search_view.py


Changes:

=====================================
gajim/common/storage/archive.py
=====================================
@@ -284,8 +284,9 @@ def _get_jid_ids_from_db(self) -> None:
             self._jid_ids[row.jid] = row
             self._jid_ids_reversed[row.jid_id] = row
 
-    def get_jid_from_id(self, jid_id: int) -> JidsTableRow:
-        return self._jid_ids_reversed[jid_id]
+    def get_jid_from_id(self, jid_id: int) -> Optional[JidsTableRow]:
+        # Use get as a fail-safe for cases where the JID ID table is incomplete
+        return self._jid_ids_reversed.get(jid_id)
 
     def get_jids_in_db(self) -> KeysView[JID]:
         return self._jid_ids.keys()


=====================================
gajim/gtk/search_view.py
=====================================
@@ -191,6 +191,8 @@ def _add_results(self) -> None:
         for msg in itertools.islice(self._results_iterator, 25):
             if self._scope == 'everywhere':
                 archive_jid = app.storage.archive.get_jid_from_id(msg.jid_id)
+                if archive_jid is None:
+                    continue
                 result_row = ResultRow(
                     msg,
                     accounts[msg.account_id],



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/c7dbd58263e5e70b8529639f414663eae64fedf7

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/c7dbd58263e5e70b8529639f414663eae64fedf7
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to