refactor(services): add a generic storage counter

This commit is contained in:
Houkime 2023-04-17 14:02:07 +00:00 committed by Inex Code
parent 0a9848be47
commit c2cd972805
2 changed files with 9 additions and 5 deletions

View file

@ -113,7 +113,7 @@ class Gitea(Service):
def get_storage_usage() -> int:
storage_usage = 0
for folder in Gitea.get_folders():
storage_usage += get_storage_usage()
storage_usage += get_storage_usage(folder)
return storage_usage
@staticmethod

View file

@ -8,6 +8,8 @@ from selfprivacy_api.jobs import Job
from selfprivacy_api.utils.block_devices import BlockDevice
from selfprivacy_api.services.generic_size_counter import get_storage_usage
class ServiceStatus(Enum):
"""Enum for service status"""
@ -120,10 +122,12 @@ class Service(ABC):
def get_logs():
pass
@staticmethod
@abstractmethod
def get_storage_usage() -> int:
pass
@classmethod
def get_storage_usage(cls) -> int:
storage_used = 0
for folder in cls.get_folders():
storage_used += get_storage_usage(folder)
return storage_used
@staticmethod
@abstractmethod