mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
refactor(services): add a generic storage counter
This commit is contained in:
parent
0a9848be47
commit
c2cd972805
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue