Skip to content

Conversation

@AgentsLogic
Copy link

@AgentsLogic AgentsLogic commented Jan 3, 2026

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

  1. New safe_delete() function with comprehensive error handling:

    • Handles regular files, directories, symlinks, and special file types
    • Gracefully handles permission errors without crashing
    • Logs all deletion attempts and failures
    • Returns success/failure status for better control flow
  2. Enhanced deleter_thread() logic:

    • Separates directories from non-directory items (files, symlinks, etc.)
    • Deletes stray files/symlinks in log root before attempting directory deletion
    • Handles os.listdir() failures gracefully
    • Uses lstat() to properly detect symlinks without following them
    • Continues deletion even when individual items fail

Comprehensive Test Coverage

Added 8 new unit tests covering edge cases:

  1. test_delete_stray_file_in_log_root - Stray files directly in log root
  2. test_delete_symlink_in_log_root - Symlinks (verifies target is not deleted)
  3. test_delete_nested_directory_structure - Deeply nested directories with files
  4. test_delete_mixed_items_in_log_root - Mixed files, dirs, and symlinks
  5. test_delete_with_permission_errors - Recovery from permission errors
  6. test_delete_special_characters_in_names - Files with spaces, dashes, dots
  7. test_delete_empty_files_and_directories - Empty files and directories

Testing

All tests pass locally and provide comprehensive coverage of:

  • Various file types (regular files, directories, symlinks)
  • Edge cases (empty files, nested structures, special characters)
  • Error conditions (permission errors, missing files)
  • Deletion order (stray files before directories)

Fixes

Fixes #30102

@AgentsLogic AgentsLogic force-pushed the deleter-handle-non-openpilot-files branch 5 times, most recently from 81d5279 to a4b4411 Compare January 3, 2026 13:22
- Add safe_delete() function with comprehensive error handling
- Handle files, directories, symlinks, and special file types
- Gracefully handle permission errors and continue deletion
- Delete stray files/symlinks in log root before directories
- Add 8 comprehensive unit tests covering:
  * Stray files in log root
  * Symlinks (without deleting targets)
  * Nested directory structures
  * Mixed item types (files, dirs, symlinks)
  * Permission error recovery
  * Special characters in filenames
  * Empty files and directories

Fixes commaai#30102
@AgentsLogic AgentsLogic force-pushed the deleter-handle-non-openpilot-files branch from a4b4411 to cf352a2 Compare January 3, 2026 13:31
@AgentsLogic
Copy link
Author

ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deleter: handle non-openpilot created files

1 participant