mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
refactor(backups): NoneBackupper class for those cases when we do not know
This commit is contained in:
parent
3449837de9
commit
4f2f24daac
26
selfprivacy_api/backup/backuppers/none_backupper.py
Normal file
26
selfprivacy_api/backup/backuppers/none_backupper.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
||||||
|
from selfprivacy_api.backup.backuppers import AbstractBackuper
|
||||||
|
|
||||||
|
|
||||||
|
class NoneBackupper(AbstractBackuper):
|
||||||
|
def is_initted(self, repo_name: str) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def start_backup(self, folders: List[str], repo_name: str):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_snapshots(self, repo_name) -> List[Snapshot]:
|
||||||
|
"""Get all snapshots from the repo"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def init(self, repo_name):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def restore_from_backup(self, repo_name: str, snapshot_id: str, folders: List[str]):
|
||||||
|
"""Restore a target folder using a snapshot"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def restored_size(self, repo_name, snapshot_id) -> float:
|
||||||
|
raise NotImplementedError
|
|
@ -9,6 +9,7 @@ PROVIDER_MAPPING = {
|
||||||
BackupProvider.BACKBLAZE: Backblaze,
|
BackupProvider.BACKBLAZE: Backblaze,
|
||||||
BackupProvider.MEMORY: InMemoryBackup,
|
BackupProvider.MEMORY: InMemoryBackup,
|
||||||
BackupProvider.FILE: LocalFileBackup,
|
BackupProvider.FILE: LocalFileBackup,
|
||||||
|
BackupProvider.NONE: AbstractBackupProvider,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,13 @@ require different backends
|
||||||
"""
|
"""
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
from selfprivacy_api.backup.backuppers import AbstractBackuper
|
from selfprivacy_api.backup.backuppers import AbstractBackuper
|
||||||
|
from selfprivacy_api.backup.backuppers.none_backupper import NoneBackupper
|
||||||
|
|
||||||
|
|
||||||
class AbstractBackupProvider(ABC):
|
class AbstractBackupProvider(ABC):
|
||||||
@property
|
@property
|
||||||
def backuper(self) -> AbstractBackuper:
|
def backuper(self) -> AbstractBackuper:
|
||||||
raise NotImplementedError
|
return NoneBackupper
|
||||||
|
|
||||||
name = "NONE"
|
name = "NONE"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue