Repository navigation
fix: check cached file existence asynchronously before removing it - #540
Open
yamashita-room-335 wants to merge 1 commit into
Open
yamashita-room-335 wants to merge 1 commit into
yamashita-room-335 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix.
CacheStore._removeCachedFilecalls the synchronousexistsSync()before deleting a cached file. Cache cleanup,removeFileandemptyCacheall go through it. On Android with Flutter 3.29 or later this blocks the platform thread and can cause ANRs.🆕 What is the new behavior (if this is a feature change)?
The existence check uses
await file.exists(). Because the check is now asynchronous, two concurrent removals of the same entry can both see the file and race ondelete(). A failed delete is ignored when the file no longer exists and rethrown otherwise. Before, onlyPathNotFoundExceptionwas ignored, whichMemoryFileSystemdoes not throw. The version is bumped to 3.4.6.💥 Does this PR introduce a breaking change?
No.
🐛 Recommendations for testing
dart format .,flutter analyzeandflutter testpass locally on Flutter 3.47.7. The new test incache_store_test.dartuses aFilewhoseexistsSync()throws and fails without the fix. The existing test "Store should return null if file is not cached" covers the concurrent removal.📝 Links to relevant issues/docs
Fixes #539
🤔 Checklist before submitting