Skip to content

loggerd: enhance deleter to handle stray files in log root for improved robustness #35245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Aniurm
Copy link

@Aniurm Aniurm commented May 16, 2025

Description

This PR addresses issue #30102, where deleter previously failed to handle non-directory files placed directly under the log root directory (e.g., user-created stray files).

This PR modified deleter_thread to include deletion of files directly under Paths.log_root(), in addition to existing directory cleanup logic.

This is a first step — I plan to add more unit tests covering diverse file and directory structures, along with corresponding improvements to deleter in follow-up commits.

Verification

Added a unit test test_delete_stray_file_in_log_root that places a stray file in the log root and asserts it is successfully deleted. Achieved 100% test coverage for the newly added logic.

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

# delete stray files first
files = [item for item in all_items if os.path.isfile(os.path.join(log_root, item))]
for file in files:
os.remove(os.path.join(log_root, file))
Copy link
Contributor

Choose a reason for hiding this comment

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

permission error?

all_items = os.listdir(log_root)

# delete stray files first
files = [item for item in all_items if os.path.isfile(os.path.join(log_root, item))]
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't handle directories

@@ -115,3 +115,14 @@ def test_no_delete_with_lock_file(self):
self.join_thread()

assert f_path.exists(), "File deleted when locked"

def test_delete_stray_file_in_log_root(self):
f_path = self.make_file_with_data("", self.f_type, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

this test should create all sorts of random files and directories to really stress this path

@adeebshihadeh adeebshihadeh marked this pull request as draft May 25, 2025 16:32
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy