refactor(backups): clean up caps code

This commit is contained in:
Houkime 2023-08-28 17:23:21 +00:00
parent a75a102df6
commit 1fc47b049d
2 changed files with 0 additions and 25 deletions

View file

@ -396,18 +396,6 @@ class Backups:
) )
) )
@staticmethod
def set_max_auto_snapshots(value: int) -> None:
"""everything <=0 means unlimited"""
if value <= 0:
value = -1
Storage.set_max_auto_snapshots(value)
@staticmethod
def max_auto_snapshots() -> int:
"""-1 means unlimited"""
return Storage.max_auto_snapshots()
# Restoring # Restoring
@staticmethod @staticmethod

View file

@ -30,7 +30,6 @@ REDIS_INITTED_CACHE = "backups:repo_initted"
REDIS_PROVIDER_KEY = "backups:provider" REDIS_PROVIDER_KEY = "backups:provider"
REDIS_AUTOBACKUP_PERIOD_KEY = "backups:autobackup_period" REDIS_AUTOBACKUP_PERIOD_KEY = "backups:autobackup_period"
REDIS_AUTOBACKUP_MAX_KEY = "backups:autobackup_cap"
REDIS_AUTOBACKUP_QUOTAS_KEY = "backups:autobackup_quotas_key" REDIS_AUTOBACKUP_QUOTAS_KEY = "backups:autobackup_quotas_key"
redis = RedisPool().get_connection() redis = RedisPool().get_connection()
@ -45,7 +44,6 @@ class Storage:
redis.delete(REDIS_PROVIDER_KEY) redis.delete(REDIS_PROVIDER_KEY)
redis.delete(REDIS_AUTOBACKUP_PERIOD_KEY) redis.delete(REDIS_AUTOBACKUP_PERIOD_KEY)
redis.delete(REDIS_INITTED_CACHE) redis.delete(REDIS_INITTED_CACHE)
redis.delete(REDIS_AUTOBACKUP_MAX_KEY)
redis.delete(REDIS_AUTOBACKUP_QUOTAS_KEY) redis.delete(REDIS_AUTOBACKUP_QUOTAS_KEY)
prefixes_to_clean = [ prefixes_to_clean = [
@ -203,14 +201,3 @@ class Storage:
) )
return unlimited_quotas return unlimited_quotas
return AutobackupQuotas.from_pydantic(quotas_model) return AutobackupQuotas.from_pydantic(quotas_model)
@staticmethod
def set_max_auto_snapshots(value: int):
redis.set(REDIS_AUTOBACKUP_MAX_KEY, value)
@staticmethod
def max_auto_snapshots():
if redis.exists(REDIS_AUTOBACKUP_MAX_KEY):
return int(redis.get(REDIS_AUTOBACKUP_MAX_KEY))
else:
return -1