File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
ardupilot_methodic_configurator Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -599,7 +599,9 @@ def remove_created_files_and_vehicle_dir(self) -> str:
599
599
600
600
# delete all files in the vehicle directory and delete the vehicle directory
601
601
errors : list [str ] = []
602
- for item_path in vehicle_path .iterdir ():
602
+
603
+ def safe_remove_item (item_path : Path ) -> Optional [str ]:
604
+ """Safely remove a file or directory, returning error message if failed."""
603
605
try :
604
606
# If the entry is a symlink, remove the link instead of recursing into the target
605
607
if item_path .is_symlink ():
@@ -608,9 +610,16 @@ def remove_created_files_and_vehicle_dir(self) -> str:
608
610
shutil_rmtree (str (item_path ))
609
611
else :
610
612
item_path .unlink ()
613
+ return None
611
614
except OSError as e :
612
615
logging_exception (_ ("Error removing %s" ), item_path , e )
613
- errors .append (str (e ))
616
+ return str (e )
617
+
618
+ # Remove all items and collect errors
619
+ for item_path in vehicle_path .iterdir ():
620
+ error = safe_remove_item (item_path )
621
+ if error :
622
+ errors .append (error )
614
623
615
624
# Try to remove the now-empty vehicle directory
616
625
try :
You can’t perform that action at this time.
0 commit comments