From ed426f05ba3effe2ca7ef74e77969aa1a246119e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 24 Jun 2024 22:13:01 +0200 Subject: [PATCH] apps/helpers2.1: fix app env in resource upgrade context ending up in incorrect helper version being used --- src/app.py | 2 +- src/utils/resources.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app.py b/src/app.py index b729eab19..dd6acb0ef 100644 --- a/src/app.py +++ b/src/app.py @@ -770,7 +770,7 @@ def app_upgrade( from yunohost.utils.resources import 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( rollback_and_raise_exception_if_failure=True, operation_logger=operation_logger, diff --git a/src/utils/resources.py b/src/utils/resources.py index 3e41044ea..ea6448c36 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -39,10 +39,11 @@ logger = getActionLogger("yunohost.app_resources") 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.current = current self.wanted = wanted + self.workdir = workdir if "resources" not in self.current: self.current["resources"] = {} @@ -256,17 +257,17 @@ class AppResource: ) 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( self.app, - workdir=tmpdir, + workdir=workdir, action=f"{action}_{self.type}", force_include_app_settings=True, ) env_.update(env) - script_path = f"{tmpdir}/{action}_{self.type}" + script_path = f"{workdir}/{action}_{self.type}" script = f""" source /usr/share/yunohost/helpers ynh_abort_if_errors