Skip to content

Commit e646f7c

Browse files
authored
check if packages die exists before deleting
1 parent 2308612 commit e646f7c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

platform.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ def _get_tool_paths(self, tool_name: str) -> Dict[str, str]:
165165
tool_path = os.path.join(self.packages_dir, tool_name)
166166
# Remove all directories containing '@' in their name
167167
try:
168-
for item in os.listdir(self.packages_dir):
169-
if '@' in item and item.startswith(tool_name):
170-
item_path = os.path.join(self.packages_dir, item)
171-
if os.path.isdir(item_path):
172-
safe_remove_directory(item_path)
173-
logger.debug(f"Removed directory with '@' in name: {item_path}")
168+
if os.path.exists(self.packages_dir) and os.path.isdir(self.packages_dir):
169+
for item in os.listdir(self.packages_dir):
170+
if '@' in item and item.startswith(tool_name):
171+
item_path = os.path.join(self.packages_dir, item)
172+
if os.path.isdir(item_path):
173+
safe_remove_directory(item_path)
174+
logger.debug(f"Removed directory with '@' in name: {item_path}")
175+
174176
except OSError as e:
175177
logger.error(f"Error scanning packages directory for '@' directories: {e}")
176178

0 commit comments

Comments
 (0)