Skip to content

Commit 6cab017

Browse files
committed
Fix version conflict
2 parents d08343d + 5999b48 commit 6cab017

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

hassio/addons/addon.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def __init__(self, config, loop, dock, data, slug):
4141
self.data = data
4242
self._id = slug
4343

44-
self.addon_docker = DockerAddon(config, loop, dock, self)
44+
self.docker = DockerAddon(config, loop, dock, self)
4545

4646
async def load(self):
4747
"""Async initialize of object."""
4848
if self.is_installed:
49-
await self.addon_docker.attach()
49+
await self.docker.attach()
5050

5151
@property
5252
def slug(self):
@@ -434,7 +434,7 @@ async def install(self, version=None):
434434
self.path_data.mkdir()
435435

436436
version = version or self.last_version
437-
if not await self.addon_docker.install(version):
437+
if not await self.docker.install(version):
438438
return False
439439

440440
self._set_install(version)
@@ -443,7 +443,7 @@ async def install(self, version=None):
443443
@check_installed
444444
async def uninstall(self):
445445
"""Remove a addon."""
446-
if not await self.addon_docker.remove():
446+
if not await self.docker.remove():
447447
return False
448448

449449
if self.path_data.is_dir():
@@ -459,7 +459,7 @@ async def state(self):
459459
if not self.is_installed:
460460
return STATE_NONE
461461

462-
if await self.addon_docker.is_running():
462+
if await self.docker.is_running():
463463
return STATE_STARTED
464464
return STATE_STOPPED
465465

@@ -469,30 +469,34 @@ def start(self):
469469
470470
Return a coroutine.
471471
"""
472-
return self.addon_docker.run()
472+
return self.docker.run()
473473

474474
@check_installed
475475
def stop(self):
476476
"""Stop addon.
477477
478478
Return a coroutine.
479479
"""
480-
return self.addon_docker.stop()
480+
return self.docker.stop()
481481

482482
@check_installed
483483
async def update(self, version=None):
484484
"""Update addon."""
485485
version = version or self.last_version
486+
last_state = await self.state()
486487

487488
if version == self.version_installed:
488489
_LOGGER.warning(
489490
"Addon %s is already installed in %s", self._id, version)
490491
return False
491492

492-
if not await self.addon_docker.update(version):
493+
if not await self.docker.update(version):
493494
return False
494-
495495
self._set_update(version)
496+
497+
# restore state
498+
if last_state == STATE_STARTED:
499+
return await self.docker.run()
496500
return True
497501

498502
@check_installed
@@ -501,23 +505,23 @@ def restart(self):
501505
502506
Return a coroutine.
503507
"""
504-
return self.addon_docker.restart()
508+
return self.docker.restart()
505509

506510
@check_installed
507511
def logs(self):
508512
"""Return addons log output.
509513
510514
Return a coroutine.
511515
"""
512-
return self.addon_docker.logs()
516+
return self.docker.logs()
513517

514518
@check_installed
515519
async def snapshot(self, tar_file):
516520
"""Snapshot a state of a addon."""
517521
with TemporaryDirectory(dir=str(self.config.path_tmp)) as temp:
518522
# store local image
519523
if self.need_build and not await \
520-
self.addon_docker.export_image(Path(temp, "image.tar")):
524+
self.docker.export_image(Path(temp, "image.tar")):
521525
return False
522526

523527
data = {
@@ -582,15 +586,15 @@ def _extract_tar():
582586

583587
# check version / restore image
584588
version = data[ATTR_VERSION]
585-
if version != self.addon_docker.version:
589+
if version != self.docker.version:
586590
image_file = Path(temp, "image.tar")
587591
if image_file.is_file():
588-
await self.addon_docker.import_image(image_file, version)
592+
await self.docker.import_image(image_file, version)
589593
else:
590-
if await self.addon_docker.install(version):
591-
await self.addon_docker.cleanup()
594+
if await self.docker.install(version):
595+
await self.docker.cleanup()
592596
else:
593-
await self.addon_docker.stop()
597+
await self.docker.stop()
594598

595599
# restore data
596600
def _restore_data():

hassio/addons/git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ async def clone(self):
4848
try:
4949
_LOGGER.info("Clone addon %s repository", self.url)
5050
self.repo = await self.loop.run_in_executor(
51-
None, git.Repo.clone_from, self.url, str(self.path))
51+
None, git.Repo.clone_from, self.url, str(self.path),
52+
recursive=True)
5253

5354
except (git.InvalidGitRepositoryError, git.NoSuchPathError,
5455
git.GitCommandError) as err:

hassio/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Const file for HassIO."""
22
from pathlib import Path
33

4-
HASSIO_VERSION = '0.52'
4+
HASSIO_VERSION = '0.53'
55

66
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
77
'hassio/{}/version.json')

hassio/dock/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,15 @@ def _update(self, tag):
251251
252252
Need run inside executor.
253253
"""
254-
was_running = self._is_running()
255-
256254
_LOGGER.info(
257255
"Update docker %s with %s:%s", self.version, self.image, tag)
258256

259257
# update docker image
260258
if not self._install(tag):
261259
return False
262260

263-
# run or cleanup container
264-
if was_running:
265-
self._run()
266-
else:
267-
self._stop()
261+
# container
262+
self._stop()
268263

269264
# cleanup images
270265
self._cleanup()

hassio/homeassistant.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ async def update(self, version=None):
121121
_LOGGER.warning("Version %s is already installed", version)
122122
return False
123123

124-
return await self.docker.update(version)
124+
try:
125+
return await self.docker.update(version)
126+
finally:
127+
await self.docker.run()
125128

126129
def run(self):
127130
"""Run HomeAssistant docker.

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"hassio": "0.52",
2+
"hassio": "0.53",
33
"homeassistant": "0.51.2",
44
"resinos": "1.0",
55
"resinhup": "0.3",

0 commit comments

Comments
 (0)