mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Return an error when doing two purges on a room
Queuing up purges doesn't sound like a good thing.
This commit is contained in:
parent
b984dd0b73
commit
1708412f56
@ -50,15 +50,26 @@ class MessageHandler(BaseHandler):
|
|||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
|
|
||||||
self.pagination_lock = ReadWriteLock()
|
self.pagination_lock = ReadWriteLock()
|
||||||
|
self._purges_in_progress_by_room = set()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def purge_history(self, room_id, topological_ordering,
|
def purge_history(self, room_id, topological_ordering,
|
||||||
delete_local_events=False):
|
delete_local_events=False):
|
||||||
with (yield self.pagination_lock.write(room_id)):
|
if room_id in self._purges_in_progress_by_room:
|
||||||
yield self.store.purge_history(
|
raise SynapseError(
|
||||||
room_id, topological_ordering, delete_local_events,
|
400,
|
||||||
|
"History purge already in progress for %s" % (room_id, ),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._purges_in_progress_by_room.add(room_id)
|
||||||
|
try:
|
||||||
|
with (yield self.pagination_lock.write(room_id)):
|
||||||
|
yield self.store.purge_history(
|
||||||
|
room_id, topological_ordering, delete_local_events,
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
self._purges_in_progress_by_room.discard(room_id)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_messages(self, requester, room_id=None, pagin_config=None,
|
def get_messages(self, requester, room_id=None, pagin_config=None,
|
||||||
as_client_event=True, event_filter=None):
|
as_client_event=True, event_filter=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user