mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-26 14:01:30 +00:00
refactor(backups): make localfile repos normal
This commit is contained in:
parent
cbedd196e4
commit
9e0b0d8caa
|
@ -31,8 +31,7 @@ class Backups:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_localfile_repo(file_path: str):
|
def set_localfile_repo(file_path: str):
|
||||||
ProviderClass = get_provider(BackupProvider.FILE)
|
ProviderClass = get_provider(BackupProvider.FILE)
|
||||||
provider = ProviderClass(file_path)
|
provider = ProviderClass(login="", key="", location=file_path, repo_id="")
|
||||||
Storage.store_testrepo_path(file_path)
|
|
||||||
Storage.store_provider(provider)
|
Storage.store_provider(provider)
|
||||||
|
|
||||||
def set_provider(provider: AbstractBackupProvider):
|
def set_provider(provider: AbstractBackupProvider):
|
||||||
|
@ -145,10 +144,6 @@ class Backups:
|
||||||
):
|
):
|
||||||
provider_class = get_provider(BackupProvider[kind])
|
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)
|
return provider_class(login=login, key=key, location=location, repo_id=repo_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -3,12 +3,5 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
|
||||||
|
|
||||||
|
|
||||||
class LocalFileBackup(AbstractBackupProvider):
|
class LocalFileBackup(AbstractBackupProvider):
|
||||||
backuper = ResticBackuper("", "", "memory")
|
backuper = ResticBackuper("", "", ":local:")
|
||||||
|
|
||||||
name = "FILE"
|
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)
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ def file_backup(tmpdir) -> AbstractBackupProvider:
|
||||||
test_repo_path = path.join(tmpdir, "test_repo")
|
test_repo_path = path.join(tmpdir, "test_repo")
|
||||||
ProviderClass = providers.get_provider(BackupProvider.FILE)
|
ProviderClass = providers.get_provider(BackupProvider.FILE)
|
||||||
assert ProviderClass is not None
|
assert ProviderClass is not None
|
||||||
provider = ProviderClass(test_repo_path)
|
provider = ProviderClass(location=test_repo_path)
|
||||||
assert provider is not None
|
assert provider is not None
|
||||||
return provider
|
return provider
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue