mirror of
https://github.com/element-hq/synapse
synced 2024-09-01 12:10:21 +00: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
1 changed files with 14 additions and 3 deletions
|
@ -50,14 +50,25 @@ class MessageHandler(BaseHandler):
|
|||
self.clock = hs.get_clock()
|
||||
|
||||
self.pagination_lock = ReadWriteLock()
|
||||
self._purges_in_progress_by_room = set()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def purge_history(self, room_id, topological_ordering,
|
||||
delete_local_events=False):
|
||||
if room_id in self._purges_in_progress_by_room:
|
||||
raise SynapseError(
|
||||
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
|
||||
def get_messages(self, requester, room_id=None, pagin_config=None,
|
||||
|
|
Loading…
Reference in a new issue