mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00:00
Create add-on config folder on add-on start (#4690)
This commit is contained in:
parent
68da328cc5
commit
d7d34d36c8
@ -622,12 +622,6 @@ class Addon(AddonModel):
|
||||
)
|
||||
self.path_data.mkdir()
|
||||
|
||||
if self.addon_config_used and not self.path_config.is_dir():
|
||||
_LOGGER.info(
|
||||
"Creating Home Assistant add-on config folder %s", self.path_config
|
||||
)
|
||||
self.path_config.mkdir()
|
||||
|
||||
# Setup/Fix AppArmor profile
|
||||
await self.install_apparmor()
|
||||
|
||||
@ -899,6 +893,18 @@ class Addon(AddonModel):
|
||||
if self.with_audio:
|
||||
self.write_pulse()
|
||||
|
||||
def _check_addon_config_dir():
|
||||
if self.path_config.is_dir():
|
||||
return
|
||||
|
||||
_LOGGER.info(
|
||||
"Creating Home Assistant add-on config folder %s", self.path_config
|
||||
)
|
||||
self.path_config.mkdir()
|
||||
|
||||
if self.addon_config_used:
|
||||
await self.sys_run_in_executor(_check_addon_config_dir)
|
||||
|
||||
# Start Add-on
|
||||
self._startup_event.clear()
|
||||
try:
|
||||
|
@ -649,16 +649,13 @@ async def test_start_when_running(
|
||||
assert "local_ssh is already running" in caplog.text
|
||||
|
||||
|
||||
async def test_install(
|
||||
async def test_local_example_install(
|
||||
coresys: CoreSys, container: MagicMock, tmp_supervisor_data: Path, repository
|
||||
):
|
||||
"""Test install of an addon."""
|
||||
assert not (
|
||||
data_dir := tmp_supervisor_data / "addons" / "data" / "local_example"
|
||||
).exists()
|
||||
assert not (
|
||||
config_dir := tmp_supervisor_data / "addon_configs" / "local_example"
|
||||
).exists()
|
||||
|
||||
with patch.object(
|
||||
CpuArch, "supported", new=PropertyMock(return_value=["aarch64"])
|
||||
@ -667,4 +664,24 @@ async def test_install(
|
||||
install.assert_called_once()
|
||||
|
||||
assert data_dir.is_dir()
|
||||
assert config_dir.is_dir()
|
||||
|
||||
|
||||
async def test_local_example_start(
|
||||
coresys: CoreSys,
|
||||
container: MagicMock,
|
||||
tmp_supervisor_data: Path,
|
||||
install_addon_example: Addon,
|
||||
):
|
||||
"""Test start of an addon."""
|
||||
install_addon_example.path_data.mkdir()
|
||||
await install_addon_example.load()
|
||||
await asyncio.sleep(0)
|
||||
assert install_addon_example.state == AddonState.STOPPED
|
||||
|
||||
assert not (
|
||||
addon_config_dir := tmp_supervisor_data / "addon_configs" / "local_example"
|
||||
).exists()
|
||||
|
||||
await install_addon_example.start()
|
||||
|
||||
assert addon_config_dir.is_dir()
|
||||
|
Loading…
x
Reference in New Issue
Block a user