Philipp Hörist pushed to branch master at gajim / gajim
Commits:
f1dbec4f by Philipp Hörist at 2024-04-12T22:00:35+02:00
cfix: Migration: Make mam state migration more resilient
- - - - -
1 changed file:
- gajim/common/storage/archive/migration.py
Changes:
=====================================
gajim/common/storage/archive/migration.py
=====================================
@@ -220,7 +220,6 @@ def _process_archive_row(
archive_row: LastArchiveMessage,
account_pks: list[int],
) -> None:
-
if archive_row.remote is None:
log.warning(
'Unable to migrate mam state because jid_id %s was not found',
@@ -246,16 +245,25 @@ def _process_archive_row(
float(archive_row.oldest_mam_timestamp), tz=timezone.utc
)
+ if (from_stanza_ts, to_stanza_id, to_stanza_ts) == (None, None, None):
+ return
+
for account_pk in account_pks:
- conn.execute(
- sa.insert(mod.MAMArchiveState).values(
- fk_account_pk=account_pk,
- fk_remote_pk=remote_pk,
- from_stanza_ts=from_stanza_ts,
- to_stanza_id=to_stanza_id,
- to_stanza_ts=to_stanza_ts,
+ try:
+ conn.execute(
+ sa.insert(mod.MAMArchiveState).values(
+ fk_account_pk=account_pk,
+ fk_remote_pk=remote_pk,
+ from_stanza_ts=from_stanza_ts,
+ to_stanza_id=to_stanza_id,
+ to_stanza_ts=to_stanza_ts,
+ )
)
- )
+ except IntegrityError:
+ log.warning(
+ 'Unable to migrate mam archive state, because it was
already migrated'
+ )
+ return
def _process_message_row(self, conn: sa.Connection, log_row: Logs) -> None:
m_type, direction = KIND_MAPPING[log_row.kind]
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/f1dbec4ff5bb89f8524584841d9827030c180729
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/f1dbec4ff5bb89f8524584841d9827030c180729
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]