mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-03-12 09:44:09 +00:00
refactor(service): move finishing the job out of moving function
This commit is contained in:
parent
534d965cab
commit
70a0287794
2 changed files with 7 additions and 9 deletions
selfprivacy_api/services
|
@ -365,14 +365,6 @@ class Service(ABC):
|
||||||
report_progress(95, job, f"Finishing moving {service_name}...")
|
report_progress(95, job, f"Finishing moving {service_name}...")
|
||||||
self.set_location(new_volume)
|
self.set_location(new_volume)
|
||||||
|
|
||||||
Jobs.update(
|
|
||||||
job=job,
|
|
||||||
status=JobStatus.FINISHED,
|
|
||||||
result=f"{service_name} moved successfully.",
|
|
||||||
status_text=f"Starting {service_name}...",
|
|
||||||
progress=100,
|
|
||||||
)
|
|
||||||
|
|
||||||
def move_to_volume(self, volume: BlockDevice, job: Job) -> Job:
|
def move_to_volume(self, volume: BlockDevice, job: Job) -> Job:
|
||||||
service_name = self.get_display_name()
|
service_name = self.get_display_name()
|
||||||
|
|
||||||
|
@ -384,6 +376,13 @@ class Service(ABC):
|
||||||
with StoppedService(self):
|
with StoppedService(self):
|
||||||
report_progress(9, job, "Stopped service, starting the move...")
|
report_progress(9, job, "Stopped service, starting the move...")
|
||||||
self.do_move_to_volume(volume, job)
|
self.do_move_to_volume(volume, job)
|
||||||
|
Jobs.update(
|
||||||
|
job=job,
|
||||||
|
status=JobStatus.FINISHED,
|
||||||
|
result=f"{service_name} moved successfully.",
|
||||||
|
status_text=f"Starting {service_name}...",
|
||||||
|
progress=100,
|
||||||
|
)
|
||||||
|
|
||||||
return job
|
return job
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,5 @@ class DummyService(Service):
|
||||||
if self.simulate_moving is False:
|
if self.simulate_moving is False:
|
||||||
return super(DummyService, self).do_move_to_volume(volume, job)
|
return super(DummyService, self).do_move_to_volume(volume, job)
|
||||||
else:
|
else:
|
||||||
Jobs.update(job, status=JobStatus.FINISHED)
|
|
||||||
self.set_drive(volume.name)
|
self.set_drive(volume.name)
|
||||||
return job
|
return job
|
||||||
|
|
Loading…
Add table
Reference in a new issue