Repository navigation
fix(cache): preserve root directory and handle empty folder on filesystem flush - #14515
Conversation
Track deletion status across entries during directory traversal and return false when files or subdirectories cannot be deleted.
…tem-flush-empty-and-rmdir-bug fix(cache): preserve root directory and handle empty folder on filesystem flush
|
Review complete. No issues found — approved ✅. This PR reworks the
Reviewed commit: 3e9e3ec |
🔵 Tier A · Mergeable after minor fixes
The filesystem cache flush now handles empty directories, keeps the cache root, and reports deletion failures while removing nested contents. Regression tests cover empty flushes and root preservation, and the latest update switches directory enumeration to include dot-prefixed entries and avoid traversing directory symlinks. Latest changes: The latest commit replaces glob-based enumeration with scandir so flush includes dot-prefixed entries and unlinks directory symlinks instead of traversing them.
Fix with agent prompt### Issue 1
packages/cache/src/Adapter/Filesystem.php:173-174
**Add a regression test for dot-prefixed cache entries**
The `scandir` change makes dot-prefixed cache entries removable, but the filesystem tests do not create one and assert it is gone after `flush()`. A regression could therefore leave hidden entries behind while reporting success.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 2
✅ Fixed since the last review · 1
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
| foreach (array_diff($entries, ['.', '..']) as $entry) { | ||
| $file = $path . $entry; |
There was a problem hiding this comment.
Add a regression test for dot-prefixed cache entries
The scandir change makes dot-prefixed cache entries removable, but the filesystem tests do not create one and assert it is gone after flush(). A regression could therefore leave hidden entries behind while reporting success.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cache/src/Adapter/Filesystem.php
Line: 173-174
Comment:
**Add a regression test for dot-prefixed cache entries**
The `scandir` change makes dot-prefixed cache entries removable, but the filesystem tests do not create one and assert it is gone after `flush()`. A regression could therefore leave hidden entries behind while reporting success.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Filesystem::flush()threw on an empty cache directory (glob()returns[], which! $filestreated as a failure) and removed the cache root itself, soping()returned false afterwards and the nextflush()threw.glob() === falseas an error.flush()empties the root but keeps it; nested directories are still removed, and the result is false if any file or directory could not be deleted.Verified:
packages/cacheunit suite in theappwrite-devcontainer: 116 tests passed, 2 skipped.FilesystemTeston the host:testFlushEmptyandtestFlushKeepsRootfail againstmain's adapter and pass with this change.bin/monorepo check cache: Rector and Pint passed. PHPStan reports 10 errors, all in the untouchedRedis.php/RedisCluster.php; the same errors appear in the container run.Closes #14007
Related: #14059 (merged into this branch), #14033 (superseded)