mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-11 20:53:12 -06:00
* Bump to python 3.10 * 3.10 is not a number * Musllinux wheels link * Revert attrs 22.1.0 -> 21.2.0 for wheel * Revert cryptography for wheel & pylint fix * Precommit and devcontainer to 3.10 * pyupgrade rewriting things * revert * Update builder.yml * fix rust * Update builder.yml Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
"""Helpers to check and fix issues with free space."""
|
|
import logging
|
|
|
|
from ...backups.const import BackupType
|
|
from ...coresys import CoreSys
|
|
from ..const import MINIMUM_FULL_BACKUPS, ContextType, IssueType, SuggestionType
|
|
from .base import FixupBase
|
|
|
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
|
|
|
|
|
def setup(coresys: CoreSys) -> FixupBase:
|
|
"""Check setup function."""
|
|
return FixupSystemClearFullBackup(coresys)
|
|
|
|
|
|
class FixupSystemClearFullBackup(FixupBase):
|
|
"""Storage class for fixup."""
|
|
|
|
async def process_fixup(self, reference: str | None = None) -> None:
|
|
"""Initialize the fixup class."""
|
|
full_backups = [
|
|
x for x in self.sys_backups.list_backups if x.sys_type == BackupType.FULL
|
|
]
|
|
|
|
if len(full_backups) < MINIMUM_FULL_BACKUPS:
|
|
return
|
|
|
|
_LOGGER.info("Starting removal of old full backups")
|
|
for backup in sorted(full_backups, key=lambda x: x.date)[:-1]:
|
|
self.sys_backups.remove(backup)
|
|
|
|
@property
|
|
def suggestion(self) -> SuggestionType:
|
|
"""Return a SuggestionType enum."""
|
|
return SuggestionType.CLEAR_FULL_BACKUP
|
|
|
|
@property
|
|
def context(self) -> ContextType:
|
|
"""Return a ContextType enum."""
|
|
return ContextType.SYSTEM
|
|
|
|
@property
|
|
def issues(self) -> list[IssueType]:
|
|
"""Return a IssueType enum list."""
|
|
return [IssueType.FREE_SPACE]
|