Skip to content

fix(cache): keep filesystem root intact across flush() - #14033

Open
cursor[bot] wants to merge 4 commits into
mainfrom
fix-14007-filesystem-cache-flush
Open

cursor[bot] wants to merge 4 commits into
mainfrom
fix-14007-filesystem-cache-flush

Conversation

@cursor

@cursor cursor Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Filesystem cache flush() so empty directories are treated as success (glob() returning [] is not an error), and so flush clears cache entries without deleting the configured root directory. That keeps ping() true and makes repeated flush() calls idempotent.

Test Plan

  • Added FilesystemTest::testFlushKeepsRootAndIsIdempotent() covering empty flush, populated flush, root retention, ping, and a second flush.
  • Existing Base::testFlush() continues to assert entries are cleared.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web View Automation 

Empty directories no longer trip deleteDirectory()'s glob check, and
flush() clears entries without removing the configured cache root so
ping() and repeated flush() calls stay valid.

Fixes #14007

Co-authored-by: chiragaggarwal5k <[email protected]>
@cursor
cursor Bot requested a review from ChiragAgg5k October 1, 2026 03:44
@cursor
cursor Bot marked this pull request as ready for review October 1, 2026 03:44

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@ghost

ghost commented Oct 1, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new root-user guard addresses the outstanding test failure, with no further issues found in the incremental changes.

Updates filesystem cache flushing to preserve the configured root directory, accept empty directories, and report entry deletion failures. Adds regression coverage for root retention, idempotent flushing, and deletion failures, with platform and root-user skips for the permission-based test.

Latest changes: The newest commit skips the permission-based deletion-failure test when running as root, where directory write permissions do not prevent unlinking.

Verdict New comments Fixed Still open
💬 Commented 0 1 0

Note

@cursor[bot] does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 2
File Change
packages/cache/src/Adapter/Filesystem.php Preserves the cache root, accepts empty directories, and propagates deletion failures.
packages/cache/tests/FilesystemTest.php Tests root retention, repeated flushing, and deletion failure reporting; skips the permission test on Windows and for root.
✅ Fixed since the last review · 1
  • Account for privileged users in the permission-based test · packages/cache/tests/FilesystemTest.php:109

Reviewed the commits since 0164218 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-14007-filesystem-cache-flush (after).

Metric Before After Change
🚀 Requests/sec 205.63 206.64 ⚪ +0.5%
⏱️ Latency P50 81.62 ms 83.03 ms ⚪ +1.7%
⏱️ Latency P95 199.61 ms 199.32 ms ⚪ -0.1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 83.03 199.32 12,882 206.64 -0.29
Account 166.13 313.29 678 11.26 +3.98
TablesDB 79.43 148.92 7,006 114.21 -6.11
Storage 78.14 171.07 3,390 57.26 +0.85
Functions 120.29 240.19 1,808 31.15 -0.3

Top API waits (after)

API request Max wait (ms)
functions.variables.update 490.99
account.prefs.update 481.41
functions.variables.create 455.69
account.name.update 426.71
storage.files.create 417.98

When preserving the cache root, still return false if unlink or nested
directory removal fails so flush() does not report success while entries
remain.

Co-authored-by: chiragaggarwal5k <[email protected]>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread packages/cache/tests/FilesystemTest.php Resolved
CI unit jobs run as root, which can unlink files in a non-writable
directory, so the permission-based regression cannot be simulated there.

Co-authored-by: chiragaggarwal5k <[email protected]>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

This branch has not been deployed

No deployments
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.

Calling flush() on a cache backed by the Filesystem adapter leads runtime failures

1 participant