fix(backups): return type of encryption key

restic-rewrite-api
Inex Code 2023-06-14 01:40:53 +03:00
parent 0ef6569d97
commit f4df1f6a62
3 changed files with 5 additions and 4 deletions

View File

@ -15,13 +15,13 @@ redis = RedisPool().get_connection()
class LocalBackupSecret:
@staticmethod
def get():
def get() -> str:
"""A secret string which backblaze/other clouds do not know.
Serves as encryption key.
"""
if not LocalBackupSecret.exists():
LocalBackupSecret.reset()
return redis.get(REDIS_KEY)
return redis.get(REDIS_KEY) # type: ignore
@staticmethod
def set(secret: str):

View File

@ -12,6 +12,8 @@ class AbstractBackupProvider(ABC):
def backuper(self) -> AbstractBackuper:
raise NotImplementedError
name = "NONE"
def __init__(self, login="", key="", location="", repo_id=""):
self.backuper.set_creds(login, key, location)
self.login = login

View File

@ -28,10 +28,9 @@ class BackupConfiguration:
class Backup:
@strawberry.field
def configuration(self) -> BackupConfiguration:
encryption_key = LocalBackupSecret.get()
return BackupConfiguration(
provider=BackupProvider[Backups.provider().name],
encryption_key=encryption_key.decode() if encryption_key else "",
encryption_key=LocalBackupSecret.get(),
is_initialized=Backups.is_initted(),
autobackup_period=Backups.autobackup_period_minutes(),
location_name=Backups.provider().location,