can not delete cache file
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 issue 中所示的 cacheObject.relativePath 删除路径和 ExternalStorageFileSystem.createFile 实现。检查文件路径是如何生成和使用的,然后验证删除缓存对象时会删除外部存储中的相应文件,同时不会破坏现有的缺失文件处理逻辑。当此文件系统创建的缓存文件可以成功删除时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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);
}
}
}
`
- 主要语言
- Dart
- 星标
- 812
- 派生
- 511
- 平均合并
- 28 分钟
- 30 天内合并 PR
- 12
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Baseflow/flutter_cache_manager 的其他 Issue
-
JsonCacheInfoRepository: FormatException: Unexpected end of input (at character 1) ^可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
Baseflow/flutter_cache_manager#450 · 9 条评论 · 8 个 reaction ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
Baseflow/flutter_cache_manager#535 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 30/100
Baseflow/flutter_cache_manager#508 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 48/100
Baseflow/flutter_cache_manager#507 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 30/100
Baseflow/flutter_cache_manager#501 · 1 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
查看 Baseflow/flutter_cache_manager 的全部 Issue
相似的 Issue
-
[BUG]暗黑模式下延迟字体颜色未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 66/100
-
area: youtube bug issue linux needs logs windows
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
Notsfsssf/pixez-flutter#1379 ·
维护者通常 2 天内回复