loggerd: enhance deleter robustness for non-openpilot files #36977
+273
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #30102 by making the deleter more robust when handling non-openpilot created files and directories in the log root.
Changes
Core Improvements
New
safe_delete()function with comprehensive error handling:Enhanced
deleter_thread()logic:os.listdir()failures gracefullylstat()to properly detect symlinks without following themComprehensive Test Coverage
Added 8 new unit tests covering edge cases:
test_delete_stray_file_in_log_root- Stray files directly in log roottest_delete_symlink_in_log_root- Symlinks (verifies target is not deleted)test_delete_nested_directory_structure- Deeply nested directories with filestest_delete_mixed_items_in_log_root- Mixed files, dirs, and symlinkstest_delete_with_permission_errors- Recovery from permission errorstest_delete_special_characters_in_names- Files with spaces, dashes, dotstest_delete_empty_files_and_directories- Empty files and directoriesTesting
All tests pass locally and provide comprehensive coverage of:
Fixes
Fixes #30102