refactor(backups): make a backup job running when the backup code itself is executed

This commit is contained in:
Houkime 2023-04-24 16:37:07 +00:00
parent c0dfbb3ca2
commit ad6cc5e1bc

View file

@ -14,6 +14,7 @@ from selfprivacy_api.backup.providers.provider import AbstractBackupProvider
from selfprivacy_api.backup.providers import get_provider from selfprivacy_api.backup.providers import get_provider
from selfprivacy_api.backup.storage import Storage from selfprivacy_api.backup.storage import Storage
from selfprivacy_api.backup.jobs import get_backup_job, add_backup_job from selfprivacy_api.backup.jobs import get_backup_job, add_backup_job
from selfprivacy_api.jobs import Jobs, JobStatus
class Backups: class Backups:
@ -196,8 +197,10 @@ class Backups:
folders = service.get_folders() folders = service.get_folders()
repo_name = service.get_id() repo_name = service.get_id()
if get_backup_job(service) is None: job = get_backup_job(service)
add_backup_job(service) if job is None:
job = add_backup_job(service)
Jobs.update(job, status=JobStatus.RUNNING)
service.pre_backup() service.pre_backup()
snapshot = Backups.provider().backuper.start_backup(folders, repo_name) snapshot = Backups.provider().backuper.start_backup(folders, repo_name)