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


Commits:
3c0c33a7 by Philipp Hörist at 2024-06-04T22:53:55+02:00
cfix: Migration: Don’t fail when account jid can not be determined

- - - - -


1 changed file:

- gajim/common/storage/archive/migration.py


Changes:

=====================================
gajim/common/storage/archive/migration.py
=====================================
@@ -208,10 +208,7 @@ def _v8(self) -> None:
 
             stmt = sa.select(LastArchiveMessage)
 
-            accounts = app.settings.get_accounts()
-            account_jids = [app.get_jid_from_account(account) for account in 
accounts]
-            account_jids = [JID.from_string(a) for a in account_jids]
-            account_pks = [self._get_account_pk(conn, j) for j in account_jids]
+            account_pks = self._get_account_pks(conn)
 
             for archive_row in self._archive.get_session().scalars(stmt):
                 self._process_archive_row(conn, archive_row, account_pks)
@@ -272,6 +269,21 @@ def _v11(self) -> None:
         mod.Base.metadata.create_all(self._engine)
         self._execute_multiple(['PRAGMA user_version=11'])
 
+    def _get_account_pks(self, conn: sa.Connection) -> list[int]:
+        account_pks: list[int] = []
+        for account in app.settings.get_accounts():
+            jid_str = app.get_jid_from_account(account)
+            try:
+                jid = JID.from_string(jid_str)
+            except Exception:
+                log.warning('Unable to parse account: %s', jid_str)
+                continue
+
+            pk = self._get_account_pk(conn, jid)
+            account_pks.append(pk)
+
+        return account_pks
+
     def _process_archive_row(
         self,
         conn: sa.Connection,



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

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


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to