From cbaa26f4729c9abb11ae150894f8d1032c1d8216 Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 22 Nov 2022 15:23:42 +0100 Subject: [PATCH] AppUpgrade: ask confirmation when not enough ram --- locales/en.json | 2 +- src/app.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/locales/en.json b/locales/en.json index 0daf06d90..c39687fbe 100644 --- a/locales/en.json +++ b/locales/en.json @@ -163,9 +163,9 @@ "config_validate_url": "Should be a valid web URL", "config_version_not_supported": "Config panel versions '{version}' are not supported.", "confirm_app_install_danger": "DANGER! This app is known to be still experimental (if not explicitly not working)! You should probably NOT install it unless you know what you are doing. NO SUPPORT will be provided if this app doesn't work or breaks your system... If you are willing to take that risk anyway, type '{answers}'", - "confirm_app_install_insufficient_ram": "DANGER! This app requires {required} RAM to install/upgrade but only {current} is available right now. Even if this app could run, its installation process requires a large amount of RAM so your server may freeze and fail miserably. If you are willing to take that risk anyway, type '{answers}'", "confirm_app_install_thirdparty": "DANGER! This app is not part of YunoHost's app catalog. Installing third-party apps may compromise the integrity and security of your system. You should probably NOT install it unless you know what you are doing. NO SUPPORT will be provided if this app doesn't work or breaks your system... If you are willing to take that risk anyway, type '{answers}'", "confirm_app_install_warning": "Warning: This app may work, but is not well-integrated into YunoHost. Some features such as single sign-on and backup/restore might not be available. Install anyway? [{answers}] ", + "confirm_app_insufficient_ram": "DANGER! This app requires {required} RAM to install/upgrade but only {current} is available right now. Even if this app could run, its installation/upgrade process requires a large amount of RAM so your server may freeze and fail miserably. If you are willing to take that risk anyway, type '{answers}'", "custom_app_url_required": "You must provide a URL to upgrade your custom app {app}", "danger": "Danger:", "diagnosis_apps_allgood": "All installed apps respect basic packaging practices", diff --git a/src/app.py b/src/app.py index 87aedeefc..de4636461 100644 --- a/src/app.py +++ b/src/app.py @@ -587,11 +587,16 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False upgrade_type = "UPGRADE_FULL" # Check requirements - for _, check, values, err in _check_manifest_requirements( + for name, check, values, err in _check_manifest_requirements( manifest, action="upgrade" ): if not check: - raise YunohostValidationError(err, **values) + if name == "ram": + _ask_confirmation( + "confirm_app_insufficient_ram", params=values, force=force + ) + else: + raise YunohostValidationError(err, **values) if manifest["packaging_format"] >= 2: if no_safety_backup: @@ -895,7 +900,7 @@ def app_install( if not check: if name == "ram": _ask_confirmation( - "confirm_app_install_insufficient_ram", params=values, force=force + "confirm_app_insufficient_ram", params=values, force=force ) else: raise YunohostValidationError(err, **values)