Add-on: Block update itself (#2956)

* Add-on: Block update itself

* Better logging

* Update
This commit is contained in:
Pascal Vizeli 2021-06-14 10:37:59 +02:00 committed by GitHub
parent cd8fc16bcb
commit d53d526673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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