Skip to content

Use EnumerateDirectories in local triage cache walk - #65

Open
chryzsh wants to merge 1 commit into
Mayyhem:mainfrom
chryzsh:fix-local-triage-enumeration
Open

Use EnumerateDirectories in local triage cache walk#65
chryzsh wants to merge 1 commit into
Mayyhem:mainfrom
chryzsh:fix-local-triage-enumeration

Conversation

@chryzsh

@chryzsh chryzsh commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #61. local triage walks the client's ccmcache directory recursively, and it was using Directory.GetDirectories(), which grabs every subdirectory into a list before it processes any of them. This swaps it for Directory.EnumerateDirectories(), which hands back directories one at a time as it finds them, so it can start recursing into the first one right away instead of waiting to list everything first. Same order, same output, nothing else changed.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Testing

  • Built main and this branch as merged binaries and ran local triage against a lab client's C:\Windows\ccmcache — output was identical between the two, so no behavior changed.
  • To actually see a difference, I created 10,000 empty folders under ccmcache on a lab client and ran both binaries against it. Output was still identical, but the new version used about 5.5% less peak memory (27.4 MB vs 25.9 MB) and started processing the first folder a bit sooner. Total runtime came out about the same either way — most of the time is spent on the per-directory ACL checks, not on listing directories, so this isn't really a speed fix. It's lower memory use and a quicker first result, which is what the issue asked for.

Test Configuration:

  • SCCM Site Version: N/A — this command only walks the local filesystem and never queries the SCCM site
  • SCCM Client Version: N/A — same reason

Bonus Points:

  • I have commented my code, particularly in hard-to-understand areas
  • I have incremented the build/revision number in AssemblyInfo.cs
  • I have made corresponding changes to the Wiki and RELEASE_NOTES.md
  • I have added unit tests that prove my fix is effective or that my feature works

Maintainer-requested in Mayyhem#61: swap the eager Directory.GetDirectories()
call for Directory.EnumerateDirectories() in the recursive local
triage cache walk, so recursion into the first child directory can
begin without first materializing the full array of siblings. Same
traversal order and output, no behavior change.
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.

Swap GetDirectories for EnumerateDirectories in local triage command

1 participant