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