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


Commits:
b796f8fe by Philipp Hörist at 2024-03-03T09:38:19+01:00
fix: Don’t fail on insertion error

- - - - -


2 changed files:

- gajim/common/modules/message.py
- gajim/common/storage/archive/storage.py


Changes:

=====================================
gajim/common/modules/message.py
=====================================
@@ -214,7 +214,10 @@ def _message_received(self,
             thread_id_=properties.thread,
         )
 
+
         pk = app.storage.archive.insert_object(message_data)
+        if pk == -1:
+            return
 
         app.ged.raise_event(MessageReceived(account=self._account,
                                             jid=remote_jid,


=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -185,7 +185,13 @@ def insert_object(self, obj: Any) -> int:
         self._set_foreign_keys(obj)
 
         self._session.add(obj)
-        self._session.commit()
+
+        try:
+            self._session.commit()
+        except Exception as error:
+            self._log.warning(error)
+            self._session.rollback()
+            return -1
 
         return obj.pk
 



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/b796f8fee64acafde332d2c7cd1fcdaaa80d06cd
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