Baseflow / Baseflow/flutter_cache_manager
can not delete cache file
- 主要言語
- Dart
- スター
- 809
- フォーク
- 510
- 平均マージ
- 6分
- マージ済み PR(30日)
- 1
説明
```
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);
}
}
}
`
コントリビューションガイド
調査の方向性
まず、issue に示されている cacheObject.relativePath の削除経路と ExternalStorageFileSystem.createFile の実装を追跡します。ファイルパスがどのように生成され、使用されているかを確認し、続いて、キャッシュされたオブジェクトを削除すると外部ストレージ内の対応するファイルも削除され、既存のファイル欠落処理が壊れないことを検証します。このファイルシステムによって作成されたキャッシュファイルを正常に削除できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- dart, flutter
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100