diff options
author | Mathieu Velten <mathieuv@matrix.org> | 2023-06-09 15:14:59 +0200 |
---|---|---|
committer | Mathieu Velten <mathieuv@matrix.org> | 2023-06-09 15:14:59 +0200 |
commit | 5b83e0df39a22d0e18c0ea4b942cd8139d2bd019 (patch) | |
tree | c9e2e51ea86c0d2712fcbe991145e924dfa43c3b /synapse | |
parent | Less quotes (diff) | |
download | synapse-5b83e0df39a22d0e18c0ea4b942cd8139d2bd019.tar.xz |
Address comments
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/pagination.py | 19 | ||||
-rw-r--r-- | synapse/handlers/room.py | 6 | ||||
-rw-r--r-- | synapse/handlers/room_member.py | 2 | ||||
-rw-r--r-- | synapse/rest/admin/rooms.py | 2 |
4 files changed, 16 insertions, 13 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index bf10f929dd..74fe9902a8 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -163,8 +163,8 @@ class PaginationHandler: or status == DeleteStatus.STATUS_FAILED ): # remove the delete from the list 24 hours after it completes or fails - time_since_completed = self.clock.time_msec() - timestamp - if time_since_completed >= PaginationHandler.CLEAR_PURGE_AFTER_MS: + ms_since_completed = self.clock.time_msec() - timestamp + if ms_since_completed >= PaginationHandler.CLEAR_PURGE_AFTER_MS: await self.store.delete_room_to_purge(room_id, delete_id) del self._delete_by_id[delete_id] @@ -199,12 +199,15 @@ class PaginationHandler: ) continue - # launch a purge from the DB - # it may be an interrupted purge or a scheduled one - purge_now = True if status == DeleteStatus.STATUS_PURGING else False - if status == DeleteStatus.STATUS_WAIT_PURGE: - if timestamp is None or self.clock.time_msec() >= timestamp: - purge_now = True + # If the database says we were last in the middle of purging the room, + # let's continue the purge process. + if status == DeleteStatus.STATUS_PURGING: + purge_now = True + # Or if we're at or past the scheduled purge time, let's start that one as well + elif status == DeleteStatus.STATUS_SCHEDULED_PURGE and ( + timestamp is None or self.clock.time_msec() >= timestamp + ): + purge_now = True # TODO 2 stages purge, keep memberships for a while so we don't "break" sync if purge_now: diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index b070ec39c3..0f04038068 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1815,12 +1815,12 @@ class DeleteStatus: return by get_delete_status. """ + STATUS_SHUTTING_DOWN = "shutting_down" + # Scheduled purge waiting to be launch at a specific time + STATUS_SCHEDULED_PURGE = "scheduled_purge" STATUS_PURGING = "purging" STATUS_COMPLETE = "complete" STATUS_FAILED = "failed" - STATUS_SHUTTING_DOWN = "shutting_down" - # Purge waiting to be launch at a specific time - STATUS_WAIT_PURGE = "wait_purge" # Tracks whether this request has completed. # One of STATUS_{PURGING,COMPLETE,FAILED,SHUTTING_DOWN,WAIT_PURGE}. diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index ec638a6805..27f1e3a615 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -318,7 +318,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta): await self.store.upsert_room_to_purge( room_id, delete_id, - DeleteStatus.STATUS_WAIT_PURGE, + DeleteStatus.STATUS_SCHEDULED_PURGE, timestamp=self.clock.time_msec() + self._purge_retention_period, ) diff --git a/synapse/rest/admin/rooms.py b/synapse/rest/admin/rooms.py index 7056da753b..5e4b0b4759 100644 --- a/synapse/rest/admin/rooms.py +++ b/synapse/rest/admin/rooms.py @@ -161,7 +161,7 @@ class DeleteRoomStatusByRoomIdRestServlet(RestServlet): response = [] for delete_id in delete_ids: delete = self._pagination_handler.get_delete_status(delete_id) - if delete and delete.status != DeleteStatus.STATUS_WAIT_PURGE: + if delete and delete.status != DeleteStatus.STATUS_SCHEDULED_PURGE: response += [ { "delete_id": delete_id, |