can not delete cache file
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing the cacheObject.relativePath deletion path and the ExternalStorageFileSystem.createFile implementation shown in the issue. Check how the file path is produced and used, then verify that deleting a cached object removes the corresponding file in external storage without breaking the existing missing-file handling. Done means cache files created by this file system can be deleted successfully.
Written by the indexing model from the issue text.
Description
if (toRemove.contains(cacheObject.id)) return;
toRemove.add(cacheObject.id!);
if (_memCache.containsKey(cacheObject.key)) {
_memCache.remove(cacheObject.key);
}
if (_futureCache.containsKey(cacheObject.key)) {
await _futureCache.remove(cacheObject.key);
}
final file = io.File(cacheObject.relativePath);
if (file.existsSync()) {
try {
await file.delete();
// ignore: unused_catch_clause
} on PathNotFoundException catch (e) {
// File has already been deleted. Do nothing #184
}
}
cacheObject.relativePath is not real abs file path ,delete file can not work
class CustomCacheManager {
static const key = 'tsl';
static final fileSystem = ExternalStorageFileSystem(key);
static CacheManager instance = CacheManager(
Config(key,
stalePeriod: const Duration(days: 30),
maxNrOfCacheObjects: 999999999,
fileSystem: fileSystem),
);
}
`
class ExternalStorageFileSystem implements FileSystem {
final Future _fileDir;
final String _cacheKey;
ExternalStorageFileSystem(this._cacheKey)
: _fileDir = createDirectory(_cacheKey);
static Future createDirectory(String key) async {
final baseDir = await getExternalStorageDirectory();
final path = p.join(baseDir!.path, key);
const fs = LocalFileSystem();
final directory = fs.directory(path);
await directory.create(recursive: true);
return directory;
}
@override
Future createFile(String name) async {
final directory = await _fileDir;
if (!(await directory.exists())) {
await createDirectory(_cacheKey);
}
return directory.childFile(name);
}
void emptyCache() async {
final directory = await _fileDir;
if (await directory.exists()) {
await directory.delete(recursive: true);
}
}
}
`
- Dominant language
- Dart
- Stars
- 810
- Forks
- 510
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Baseflow/flutter_cache_manager
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Baseflow/flutter_cache_manager#450 · 9 comments · 8 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
Baseflow/flutter_cache_manager#507 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
Baseflow/flutter_cache_manager#501 · 1 comment · 3 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Baseflow/flutter_cache_manager#500 · 1 comment · 3 reactions ·
All issues in Baseflow/flutter_cache_manager
Similar issues
-
ui/ux
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
error Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Bug Flutter User Feedbacks
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
getsentry/sentry-dart#4042 · 1 comment ·
-
team-infra
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100