From 30f5669489a093af9c4d71f4e362011e2267b9a4 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Fri, 30 Aug 2024 18:04:32 +0530 Subject: [PATCH] fix: don't allow uninstalling frappe... Signed-off-by: Akhil Narang --- frappe/commands/site.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 3c2c3950d1..d11b83902e 100644 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -880,6 +880,7 @@ def backup( @pass_context def remove_from_installed_apps(context, app): "Remove app from site's installed-apps list" + ensure_app_not_frappe(app) from frappe.installer import remove_from_installed_apps for site in context.sites: @@ -908,6 +909,7 @@ def remove_from_installed_apps(context, app): @pass_context def uninstall(context, app, dry_run, yes, no_backup, force): "Remove app and linked modules from site" + ensure_app_not_frappe(app) from frappe.installer import remove_app from frappe.utils.synchronization import filelock @@ -1493,6 +1495,18 @@ def add_new_user( update_password(user=user.name, pwd=password) +def ensure_app_not_frappe(app: str) -> None: + """ + Ensure that the app name passed is not 'frappe' + + :param app: Name of the app + :return: Nothing + """ + if app == "frappe": + click.secho("You cannot remove or uninstall the app `frappe`", fg="red") + sys.exit(1) + + @click.command("bypass-patch") @click.argument("patch_name") @click.option("--yes", "-y", is_flag=True, default=False, help="Pass --yes to skip confirmation")