From 76886abd7545e161194ac80e7b2562870f00a731 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 7 Jul 2025 19:02:58 +0200 Subject: [PATCH] check if packages dir exists before deleting --- platform.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platform.py b/platform.py index 79911e4..3746d54 100644 --- a/platform.py +++ b/platform.py @@ -154,12 +154,14 @@ class Espressif32Platform(PlatformBase): tool_path = os.path.join(self.packages_dir, tool_name) # Remove all directories containing '@' in their name try: - for item in os.listdir(self.packages_dir): - if '@' in item and item.startswith(tool_name): - item_path = os.path.join(self.packages_dir, item) - if os.path.isdir(item_path): - safe_remove_directory(item_path) - logger.debug(f"Removed directory with '@' in name: {item_path}") + if os.path.exists(self.packages_dir) and os.path.isdir(self.packages_dir): + for item in os.listdir(self.packages_dir): + if '@' in item and item.startswith(tool_name): + item_path = os.path.join(self.packages_dir, item) + if os.path.isdir(item_path): + safe_remove_directory(item_path) + logger.debug(f"Removed directory with '@' in name: {item_path}") + except OSError as e: logger.error(f"Error scanning packages directory for '@' directories: {e}")