mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-17 06:06:29 +00:00
Add-on: Block update itself (#2956)
* Add-on: Block update itself * Better logging * Update
This commit is contained in:
parent
cd8fc16bcb
commit
d53d526673
@ -27,9 +27,10 @@ from ..const import (
|
|||||||
ATTR_URL,
|
ATTR_URL,
|
||||||
ATTR_VERSION,
|
ATTR_VERSION,
|
||||||
ATTR_VERSION_LATEST,
|
ATTR_VERSION_LATEST,
|
||||||
|
REQUEST_FROM,
|
||||||
)
|
)
|
||||||
from ..coresys import CoreSysAttributes
|
from ..coresys import CoreSysAttributes
|
||||||
from ..exceptions import APIError
|
from ..exceptions import APIError, APIForbidden
|
||||||
from ..store.addon import AddonStore
|
from ..store.addon import AddonStore
|
||||||
from ..store.repository import Repository
|
from ..store.repository import Repository
|
||||||
|
|
||||||
@ -136,6 +137,8 @@ class APIStore(CoreSysAttributes):
|
|||||||
def addons_addon_update(self, request: web.Request) -> Awaitable[None]:
|
def addons_addon_update(self, request: web.Request) -> Awaitable[None]:
|
||||||
"""Update add-on."""
|
"""Update add-on."""
|
||||||
addon = self._extract_addon(request, installed=True)
|
addon = self._extract_addon(request, installed=True)
|
||||||
|
if addon == request.get(REQUEST_FROM):
|
||||||
|
raise APIForbidden(f"Add-on {addon.slug} can't update itself!")
|
||||||
return asyncio.shield(addon.update())
|
return asyncio.shield(addon.update())
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
|
Loading…
x
Reference in New Issue
Block a user