File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -123,17 +123,12 @@ def safe_remove_directory_pattern(base_path: str, pattern: str) -> bool:
123
123
"""Safely remove directories matching a pattern with error handling."""
124
124
if not os .path .exists (base_path ):
125
125
return True
126
-
127
- try :
128
- # Find all directories matching the pattern in the base directory
129
- for item in os .listdir (base_path ):
130
- item_path = os .path .join (base_path , item )
131
- if os .path .isdir (item_path ) and fnmatch .fnmatch (item , pattern ):
132
- shutil .rmtree (item_path )
133
- logger .debug (f"Directory removed: { item_path } " )
134
- except OSError as e :
135
- logger .error (f"Error removing directories with pattern { pattern } : { e } " )
136
- return False
126
+ # Find all directories matching the pattern in the base directory
127
+ for item in os .listdir (base_path ):
128
+ item_path = os .path .join (base_path , item )
129
+ if os .path .isdir (item_path ) and fnmatch .fnmatch (item , pattern ):
130
+ shutil .rmtree (item_path )
131
+ logger .debug (f"Directory removed: { item_path } " )
137
132
return True
138
133
139
134
You can’t perform that action at this time.
0 commit comments