mirror: allow to cancel ongoing check when starting a new one
Before, doing a POST request to /mirror/check_mirror/start when a mirror test was already running resulted in an exception on the server side. We now have a parameter to control whether any ongoing check should be cancelled first. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
d18ebd826a
commit
c8fd3e40c2
|
@ -354,7 +354,7 @@ class API:
|
|||
|
||||
class check_mirror:
|
||||
class start:
|
||||
def POST() -> None: ...
|
||||
def POST(cancel_ongoing: bool = False) -> None: ...
|
||||
|
||||
class progress:
|
||||
def GET() -> Optional[MirrorCheckResponse]: ...
|
||||
|
|
|
@ -189,10 +189,12 @@ class MirrorController(SubiquityController):
|
|||
log.debug(data)
|
||||
self.model.disabled_components = set(data)
|
||||
|
||||
async def check_mirror_start_POST(self) -> None:
|
||||
async def check_mirror_start_POST(self, cancel_ongoing: bool = False) -> None:
|
||||
if self.mirror_check is not None and not self.mirror_check.task.done():
|
||||
# TODO
|
||||
assert False
|
||||
if cancel_ongoing:
|
||||
await self.check_mirror_abort_POST()
|
||||
else:
|
||||
assert False
|
||||
output = io.StringIO()
|
||||
self.mirror_check = MirrorCheck(
|
||||
uri=self.model.get_mirror(),
|
||||
|
|
Loading…
Reference in New Issue