Skip to content

Stop obsolete folder counts during directory traversal - #119

Open
k-kostin wants to merge 2 commits into
omacom:mainfrom
k-kostin:codex/cancel-folder-counts
Open

k-kostin wants to merge 2 commits into
omacom:mainfrom
k-kostin:codex/cancel-folder-counts

Conversation

@k-kostin

Copy link
Copy Markdown

Summary

Leaving a folder invalidates its count job, but a count already running still enumerates the entire child directory. Pass the existing generation predicate into that loop so navigation, refresh or model destruction can stop obsolete work.

invalidate generation → stop counting → return unknown (-1), never a partial total

Include hidden entries in the iterator, then exclude them from the total when hidden files are off. Otherwise Qt can filter a long hidden run internally without yielding to the cancellation check. Linux hidden-name semantics and exclusion of . / .. are preserved.

Based directly on main; no dependency on #67, #117 or #118. Complements #116's pool separation by avoiding wasted counting itself. No dependency or thread-pool change.

Evidence

  • A real FolderModel with a delayed synthetic directory continued reading 981 entries after navigation on the unchanged base. The final patch reads 0–1 additional visible entries, or 0 hidden entries, in the measured runs. No partial counter is published.
  • 50 controlled runs, five alternating pairs per scenario, cover navigation, refresh, destruction and hidden directories. Navigation latency in the one-worker harness is 543 → 10 ms median. This deliberately delays real readdir64() by 500 µs per entry; it measures queue contention, not ordinary SSD navigation. Give folder listings their own thread pool; make showItem invokable #116 may remove that listing contention independently.
  • Release build, focused tests and git diff --check pass. Final complete local suite: 197 passed, 0 failed, using Qt image plugins matching the CI dependency set. Regression covers cancellation during enumeration, before starting, empty/hidden directories and a complete retry. Independent review found no remaining issues.
  • One earlier full run failed the plugin process-cleanup test. That test passed standalone on both heads, followed by a passing full pair (base 196/0, candidate 197/0) and another full pass after the hidden-entry fix. No plugin code was changed.
  • Reapplying the change to the current Open and sort large folders faster #26/Give folder listings their own thread pool; make showItem invokable #116 heads preserves their changes and passes syntax compilation. Their surrounding edits cause patch-context conflicts; full combined-branch checks remain due after any rebase.

Merge Danger

Door: two-way.

Blast Radius: folder counters. Cancellation is cooperative between iterator advances and cannot interrupt an already blocked filesystem call. The previewer's separate folder-summary path is unchanged.

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Folder counts now check whether their work is obsolete while walking each directory.

  • Folder counts stop when their listing is no longer current.

No actionable issues were found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start folder count] --> B{Generation changed?}
  B -->|Yes| C[Return unknown: -1]
  B -->|No| D[Advance directory iterator]
  D --> E[Count entry if shown]
  E --> F{More entries?}
  F -->|Yes| B
  F -->|No| G{Generation changed?}
  G -->|Yes| C
  G -->|No| H[Return complete count]
  C --> I[Discard obsolete worker results]
Loading

Reviews (1) · Last reviewed commit: "Keep hidden directory entries cancellabl..." · Reviewed by Greptile

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