diff --git a/locales/en.json b/locales/en.json
index d9d3553f0..a20abb4b6 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -273,6 +273,8 @@
"diagnosis_sshd_config_insecure": "The SSH configuration appears to have been manually modified, and is insecure because it contains no 'AllowGroups' or 'AllowUsers' directive to limit access to authorized users.",
"diagnosis_sshd_config_inconsistent": "It looks like the SSH port was manually modified in /etc/ssh/sshd_config. Since YunoHost 4.2, a new global setting 'security.ssh.port' is available to avoid manually editing the configuration.",
"diagnosis_sshd_config_inconsistent_details": "Please run yunohost settings set security.ssh.port -v YOUR_SSH_PORT to define the SSH port, and check yunohost tools regen-conf ssh --dry-run --with-diff and yunohost tools regen-conf ssh --force to reset your conf to the YunoHost recommendation.",
+ "disk_space_not_sufficient_install": "There is not enough disk space left to install this application",
+ "disk_space_not_sufficient_update": "There is not enough disk space left to update this application",
"domain_cannot_remove_main": "You cannot remove '{domain}' since it's the main domain, you first need to set another domain as the main domain using 'yunohost domain main-domain -n '; here is the list of candidate domains: {other_domains}",
"domain_cannot_add_xmpp_upload": "You cannot add domains starting with 'xmpp-upload.'. This kind of name is reserved for the XMPP upload feature integrated in YunoHost.",
"domain_cannot_remove_main_add_new_one": "You cannot remove '{domain}' since it's the main domain and your only domain, you need to first add another domain using 'yunohost domain add ', then set is as the main domain using 'yunohost domain main-domain -n ' and then you can remove the domain '{domain}' using 'yunohost domain remove {domain}'.'",
diff --git a/locales/fr.json b/locales/fr.json
index 100c84178..cb5ea2f74 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -44,6 +44,8 @@
"backup_output_directory_required": "Vous devez spécifier un dossier de destination pour la sauvegarde",
"backup_running_hooks": "Exécution des scripts de sauvegarde...",
"custom_app_url_required": "Vous devez spécifier une URL pour mettre à jour votre application personnalisée {app}",
+ "disk_space_not_sufficient_install": "Il ne reste pas assez d'espace disque pour installer cette application",
+ "disk_space_not_sufficient_update": "Il ne reste pas assez d'espace disque pour mettre à jour cette application",
"domain_cert_gen_failed": "Impossible de générer le certificat",
"domain_created": "Le domaine a été créé",
"domain_creation_failed": "Impossible de créer le domaine {domain} : {error}",
diff --git a/src/yunohost/app.py b/src/yunohost/app.py
index fd9a0c37d..0ce7a27c5 100644
--- a/src/yunohost/app.py
+++ b/src/yunohost/app.py
@@ -517,6 +517,9 @@ def app_upgrade(app=[], url=None, file=None, force=False):
from yunohost.regenconf import manually_modified_files
apps = app
+ # Check if disk space available
+ if free_space_in_directory("/") <= 512 * 1000 * 1000:
+ raise YunohostValidationError("disk_space_not_sufficient_update")
# If no app is specified, upgrade all apps
if not apps:
# FIXME : not sure what's supposed to happen if there is a url and a file but no apps...
@@ -875,6 +878,11 @@ def app_install(
manifest, extracted_app_folder = _extract_app_from_file(app)
else:
raise YunohostValidationError("app_unknown")
+
+ # Check if disk space available
+ size = os.statvfs('/')
+ if free_space_in_directory("/") <= 512 * 1000 * 1000:
+ raise YunohostValidationError("disk_space_not_sufficient_install")
# Check ID
if "id" not in manifest or "__" in manifest["id"]: