forked from MirrorHub/synapse
Add has_completed_background_update
This allows checking if a specific background update has completed.
This commit is contained in:
parent
367158a609
commit
2135c198d1
1 changed files with 24 additions and 1 deletions
|
@ -140,7 +140,7 @@ class BackgroundUpdateStore(SQLBaseStore):
|
||||||
"background_updates",
|
"background_updates",
|
||||||
keyvalues=None,
|
keyvalues=None,
|
||||||
retcol="1",
|
retcol="1",
|
||||||
desc="check_background_updates",
|
desc="has_completed_background_updates",
|
||||||
)
|
)
|
||||||
if not updates:
|
if not updates:
|
||||||
self._all_done = True
|
self._all_done = True
|
||||||
|
@ -148,6 +148,29 @@ class BackgroundUpdateStore(SQLBaseStore):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
async def has_completed_background_update(self, update_name):
|
||||||
|
"""Check if the given background update has finished running.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Deferred[bool]
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self._all_done:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if update_name in self._background_update_queue:
|
||||||
|
return False
|
||||||
|
|
||||||
|
update_exists = await self._simple_select_one_onecol(
|
||||||
|
"background_updates",
|
||||||
|
keyvalues={"update_name": update_name},
|
||||||
|
retcol="1",
|
||||||
|
desc="has_completed_background_update",
|
||||||
|
allow_none=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return not update_exists
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def do_next_background_update(self, desired_duration_ms):
|
def do_next_background_update(self, desired_duration_ms):
|
||||||
"""Does some amount of work on the next queued background update
|
"""Does some amount of work on the next queued background update
|
||||||
|
|
Loading…
Reference in a new issue