From 98142f28cd5e15199b223308e44c16a37a97e9d3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 28 Feb 2022 12:36:43 +0200 Subject: [PATCH] Improve logging of backfill count --- mautrix_telegram/portal.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index bd05eb98..540e6833 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -2815,20 +2815,21 @@ class Portal(DBPortal, BasePortal): return if limit < 0: limit = last_tgid - min_id - self.log.debug( - f"Backfilling approximately {last_tgid - min_id} messages through {source.mxid}" - ) + limit_type = "unlimited" elif self.peer_type == "channel": min_id = max(last_tgid - limit, min_id) - self.log.debug( - f"Backfilling messages after ID {min_id} (last message: {last_tgid}) " - f"through {source.mxid}" - ) + # This is now just an approximate message count, not the actual limit. + limit = last_tgid - min_id + limit_type = "channel" else: # This limit will be higher than the actual message count if there are any messages # in other DMs or normal groups, but that's not too bad. limit = min(last_tgid - min_id, limit) - self.log.debug(f"Backfilling up to {limit} messages through {source.mxid}") + limit_type = "dm/minigroup" + self.log.debug( + f"Backfilling up to {limit} messages after ID {min_id} through {source.mxid} " + f"(last message: {last_tgid}, limit type: {limit_type})" + ) with self.backfill_lock: await self._backfill(source, min_id, limit)