Skip to content

make get_newest_experiment_file more resilient to deletes#1476

Open
rfbgo wants to merge 1 commit intoGoogleCloudPlatform:developfrom
rfbgo:filestat
Open

make get_newest_experiment_file more resilient to deletes#1476
rfbgo wants to merge 1 commit intoGoogleCloudPlatform:developfrom
rfbgo:filestat

Conversation

@rfbgo
Copy link
Copy Markdown
Collaborator

@rfbgo rfbgo commented Mar 30, 2026

Previously this function got a list of files, and then got the times. This left us open to a TOCTOU race and would lead to a crash. This version should be faster and more resilient (but it's hard to test diligently..)

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the get_newest_experiment_file function to use a manual stack-based walk with os.scandir instead of pathlib.rglob. Feedback suggests broadening exception handling from FileNotFoundError to OSError to account for NotADirectoryError and PermissionError, which prevents potential regressions and improves robustness against inaccessible files or directories.

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.

1 participant