From 07e40284029910f6e8f3e31a9f9b941671a808b3 Mon Sep 17 00:00:00 2001 From: Mithun Gowda B Date: Mon, 21 Jul 2025 11:43:12 +0530 Subject: [PATCH] Update update.py Signed-off-by: Mithun Gowda B --- setup/operations/update.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup/operations/update.py b/setup/operations/update.py index a8a68ca..22d9ad4 100644 --- a/setup/operations/update.py +++ b/setup/operations/update.py @@ -335,6 +335,15 @@ def run(args: argparse.Namespace) -> int: operation = UpdateOperation() operation.setup_operation_logging(args) logger = get_logger() + # ✅ Inserted validation code + expected_home = Path.home().resolve() + actual_dir = args.install_dir.resolve() + + if not str(actual_dir).startswith(str(expected_home)): + print(f"\n[✗] Installation must be inside your user profile directory.") + print(f" Expected prefix: {expected_home}") + print(f" Provided path: {actual_dir}") + sys.exit(1) try: # Validate global arguments @@ -420,4 +429,4 @@ def run(args: argparse.Namespace) -> int: print(f"\n{Colors.YELLOW}Update cancelled by user{Colors.RESET}") return 130 except Exception as e: - return operation.handle_operation_error("update", e) \ No newline at end of file + return operation.handle_operation_error("update", e)