Skip to content

fix: resolve race condition in get_dir_file_info() when files are deleted concurrently#10407

Open
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix-dir-file-info-null
Open

fix: resolve race condition in get_dir_file_info() when files are deleted concurrently#10407
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix-dir-file-info-null

Conversation

@gr8man

@gr8man gr8man commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description
When scanning directories, get_dir_file_info() could encounter a race condition if a file was deleted right after being read by readdir(). In this scenario, get_file_info() would return null, causing an incomplete entry (lacking server_path or other keys) to be added to the result array.

This PR adds a null check to gracefully ignore files deleted mid-scan, which also prevents broken entries from being created when passing directories with $topLevelOnly = true. This fixes random test failures observed in the Commands component. A unit test has been added to ensure the correct behavior.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

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