Skip to content

Conversation

@JJ9276489
Copy link

@JJ9276489 JJ9276489 commented Dec 8, 2025

Fixes #30102

The deleter previously assumed that every entry in log_root was a valid segment directory. Stray files or broken symlinks would accumulate and prevent cleanup from progressing correctly. This change hardens the deletion logic so that unexpected non-directory entries are removed first, and failures are logged rather than crashing the thread.

Changes

  • Delete non-directory items in log_root before processing segment directories

  • Safely handle failures in os.remove, os.listdir, and shutil.rmtree

  • Preserve normal semantics:

    • skip locked segments

    • skip preserved segments

    • delete earliest eligible directory

Verification

A new test, test_delete_mixed_contents, creates a realistic mixed-state log_root containing:

  • regular files with segment-style names

  • random stray logs

  • broken symlinks

  • a valid symlink pointing to a real directory tree

  • nested directories containing files

  • a real segment directory

Before this change, the test failed due to skipped cleanup and unhandled errors.
After this change, the test passes and cleanup proceeds correctly without crashes.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • the change is something we merge
    • include a route or your device' dongle ID if relevant

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