Skip to content

Commit 76886ab

Browse files
authored
check if packages dir exists before deleting
1 parent 2927017 commit 76886ab

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
@@ -154,12 +154,14 @@ def _get_tool_paths(self, tool_name: str) -> Dict[str, str]:
154154
tool_path = os.path.join(self.packages_dir, tool_name)
155155
# Remove all directories containing '@' in their name
156156
try:
157-
for item in os.listdir(self.packages_dir):
158-
if '@' in item and item.startswith(tool_name):
159-
item_path = os.path.join(self.packages_dir, item)
160-
if os.path.isdir(item_path):
161-
safe_remove_directory(item_path)
162-
logger.debug(f"Removed directory with '@' in name: {item_path}")
157+
if os.path.exists(self.packages_dir) and os.path.isdir(self.packages_dir):
158+
for item in os.listdir(self.packages_dir):
159+
if '@' in item and item.startswith(tool_name):
160+
item_path = os.path.join(self.packages_dir, item)
161+
if os.path.isdir(item_path):
162+
safe_remove_directory(item_path)
163+
logger.debug(f"Removed directory with '@' in name: {item_path}")
164+
163165
except OSError as e:
164166
logger.error(f"Error scanning packages directory for '@' directories: {e}")
165167

0 commit comments

Comments
 (0)