refactor(backups): make localfile repos normal

pull/35/head
Houkime 2023-06-14 14:07:51 +00:00
parent cbedd196e4
commit 9e0b0d8caa
3 changed files with 4 additions and 16 deletions

View File

@ -31,8 +31,7 @@ class Backups:
@staticmethod
def set_localfile_repo(file_path: str):
ProviderClass = get_provider(BackupProvider.FILE)
provider = ProviderClass(file_path)
Storage.store_testrepo_path(file_path)
provider = ProviderClass(login="", key="", location=file_path, repo_id="")
Storage.store_provider(provider)
def set_provider(provider: AbstractBackupProvider):
@ -145,10 +144,6 @@ class Backups:
):
provider_class = get_provider(BackupProvider[kind])
if kind == "FILE":
path = Storage.get_testrepo_path()
return provider_class(path)
return provider_class(login=login, key=key, location=location, repo_id=repo_id)
@staticmethod

View File

@ -3,12 +3,5 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
class LocalFileBackup(AbstractBackupProvider):
backuper = ResticBackuper("", "", "memory")
name = "FILE"
# login and key args are for compatibility with generic provider methods. They are ignored.
def __init__(self, filename: str, login: str = "", key: str = ""):
super().__init__()
self.backuper = ResticBackuper("", "", ":local:")
self.backuper.set_creds("", "", filename)
backuper = ResticBackuper("", "", ":local:")
name = "FILE"

View File

@ -95,7 +95,7 @@ def file_backup(tmpdir) -> AbstractBackupProvider:
test_repo_path = path.join(tmpdir, "test_repo")
ProviderClass = providers.get_provider(BackupProvider.FILE)
assert ProviderClass is not None
provider = ProviderClass(test_repo_path)
provider = ProviderClass(location=test_repo_path)
assert provider is not None
return provider