apps/helpers2.1: fix app env in resource upgrade context ending up in incorrect helper version being used

This commit is contained in:
Alexandre Aubin 2024-06-24 22:13:01 +02:00
parent 2af4c157d9
commit ed426f05ba
2 changed files with 6 additions and 5 deletions

View file

@ -770,7 +770,7 @@ def app_upgrade(
from yunohost.utils.resources import AppResourceManager from yunohost.utils.resources import AppResourceManager
AppResourceManager( AppResourceManager(
app_instance_name, wanted=manifest, current=app_dict["manifest"] app_instance_name, wanted=manifest, current=app_dict["manifest"], workdir=extracted_app_folder
).apply( ).apply(
rollback_and_raise_exception_if_failure=True, rollback_and_raise_exception_if_failure=True,
operation_logger=operation_logger, operation_logger=operation_logger,

View file

@ -39,10 +39,11 @@ logger = getActionLogger("yunohost.app_resources")
class AppResourceManager: class AppResourceManager:
def __init__(self, app: str, current: Dict, wanted: Dict): def __init__(self, app: str, current: Dict, wanted: Dict, workdir=None):
self.app = app self.app = app
self.current = current self.current = current
self.wanted = wanted self.wanted = wanted
self.workdir = workdir
if "resources" not in self.current: if "resources" not in self.current:
self.current["resources"] = {} self.current["resources"] = {}
@ -256,17 +257,17 @@ class AppResource:
) )
from yunohost.hook import hook_exec_with_script_debug_if_failure from yunohost.hook import hook_exec_with_script_debug_if_failure
tmpdir = _make_tmp_workdir_for_app(app=self.app) workdir = self.manager.workdir if self.manager and self.manager.workdir else _make_tmp_workdir_for_app(app=self.app)
env_ = _make_environment_for_app_script( env_ = _make_environment_for_app_script(
self.app, self.app,
workdir=tmpdir, workdir=workdir,
action=f"{action}_{self.type}", action=f"{action}_{self.type}",
force_include_app_settings=True, force_include_app_settings=True,
) )
env_.update(env) env_.update(env)
script_path = f"{tmpdir}/{action}_{self.type}" script_path = f"{workdir}/{action}_{self.type}"
script = f""" script = f"""
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
ynh_abort_if_errors ynh_abort_if_errors