Baseflow / Baseflow/flutter_cache_manager

can not delete cache file

Đang mở
#472 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
809
Fork
510
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
1

Mô tả

```
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);
}
}
}
`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách lần theo luồng xóa của cacheObject.relativePath và phần triển khai ExternalStorageFileSystem.createFile được nêu trong issue. Kiểm tra cách đường dẫn tệp được tạo ra và sử dụng, sau đó xác minh rằng việc xóa một đối tượng đã được lưu vào bộ nhớ đệm sẽ xóa tệp tương ứng trong bộ nhớ ngoài mà không làm hỏng cơ chế xử lý tệp bị thiếu hiện có. Hoàn thành khi các tệp bộ nhớ đệm được tạo bởi hệ thống tệp này có thể được xóa thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart, flutter
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.