Add HACS, Themes
This commit is contained in:
29
custom_components/hacs/tasks/clear_old_storage.py
Normal file
29
custom_components/hacs/tasks/clear_old_storage.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Starting setup task: clear storage."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from ..base import HacsBase
|
||||
from ..enums import HacsStage
|
||||
from .base import HacsTask
|
||||
|
||||
|
||||
async def async_setup_task(hacs: HacsBase, hass: HomeAssistant) -> Task:
|
||||
"""Set up this task."""
|
||||
return Task(hacs=hacs, hass=hass)
|
||||
|
||||
|
||||
class Task(HacsTask):
|
||||
"""Clear old files from storage."""
|
||||
|
||||
stages = [HacsStage.SETUP]
|
||||
|
||||
def execute(self) -> None:
|
||||
"""Execute the task."""
|
||||
for storage_file in ("hacs",):
|
||||
path = f"{self.hacs.core.config_path}/.storage/{storage_file}"
|
||||
if os.path.isfile(path):
|
||||
self.task_logger(self.hacs.log.info, f"Cleaning up old storage file: {path}")
|
||||
os.remove(path)
|
||||
Reference in New Issue
Block a user