AppUpgrade: ask confirmation when not enough ram

This commit is contained in:
axolotle 2022-11-22 15:23:42 +01:00
parent f405bfb613
commit cbaa26f472
2 changed files with 9 additions and 4 deletions

View file

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

View file

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