Fix removeCacheFile#469
Conversation
|
@martijn00 pls merge it, clearing files doesn't work at all |
| await _futureCache.remove(cacheObject.key); | ||
| } | ||
| final file = io.File(cacheObject.relativePath); | ||
| final file = await fileSystem.createFile(cacheObject.relativePath); |
There was a problem hiding this comment.
I'm not sure this is correct. The old code only creates a reference to the file, and this code actually creates the file. So the check for the file will always be true, which is not correct.
Might there be a problem in your own code?
There was a problem hiding this comment.
@martijn00
But the file reference leads to old code that never points to the actual file, resulting in a constant accumulation of files in the cache.
Is there a possible mistake in the name of the method itself? For example, the _fileExists method uses the same fileSystem.createFile to check for the existence of a file.
|
test code: result: 1. |
|
Same problem. File will never be deleted. final file = io.File(cacheObject.relativePath);
if (file.existsSync()) {
}Previous code will fix that. final file = await fileSystem.createFile(cacheObject.relativePath); |
|
Reference #387 |
|
@SmartVive can you add some more tests to make sure the behaviour is verified? |
|
@martijn00 Do you mean adding unit tests? I did, but I'm not good at them. |
|
@martijn00 It seems like this PR is still not merged to |
## Summary Pins `flutter_cache_manager` to upstream commit `54904e499a06d0364a2b3f4ca9789e5f829f1879`, which contains the cache-file deletion fix missing from the latest hosted `3.4.1` release. ## Why `flutter_cache_manager` 3.4.1 removes sqlite rows during capacity eviction, stale eviction, `removeFile()`, and `emptyCache()`, but its delete path resolves a bare relative filename against the process CWD via `io.File(relativePath)`. That means the DB rows disappear while the cached files remain on disk, so caches can keep growing past their configured cap. The field symptom we investigated was `libCachedImageData` holding 1,823 files / 7.00 GB against the 200-object default cap. Upstream provenance: - Baseflow/flutter_cache_manager issues: Baseflow/flutter_cache_manager#472 and Baseflow/flutter_cache_manager#490 - Upstream fix PR: Baseflow/flutter_cache_manager#469 - Pinned ref: `54904e499a06d0364a2b3f4ca9789e5f829f1879` Security/blast-radius review: - The consumed package delta versus the hosted 3.4.1 release is the upstream delete fix plus its test. - No new dependencies, network calls, native code, or CI changes are introduced by the consumed package change. - The override is workspace-wide by mechanism, but grep found only `mobile/apps/photos/pubspec.yaml` declares `cached_network_image` / `flutter_cache_manager`. Known limitation: this fixes future deletions. Files already orphaned during the buggy era have no DB rows and are intentionally left. Only way to clear them is manually clearing caches. ## Test Plan - `flutter pub get` - `flutter pub get --enforce-lockfile` - `flutter analyze apps/photos` - Verified pinned `cache_store.dart` uses `fileSystem.createFile(cacheObject.relativePath)` and no longer uses `io.File(cacheObject.relativePath)` for deletion.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
fix removeCacheFile
removeCacheFile not working. because file dir is wrong.
🆕 What is the new behavior (if this is a feature change)?
removeCacheFile is working.
💥 Does this PR introduce a breaking change?
no
🐛 Recommendations for testing
📝 Links to relevant issues/docs
🤔 Checklist before submitting