Baseflow / Baseflow/flutter_cache_manager

removeFile do not remove my file

Đang mở
#168 6 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ả

## 🐛 Bug Report

I am trying to remove a specific file from the cache and clear cache too.

### Expected behavior

(The problem only occurs in Android)

My customer take a picture with the application and he can retry to take another one if the first is not good, so I want to remove the previous picture from the cache folder of the application :
/data/user/0/*package_name*/cache/customCache/*file_name*

But nothing happens when I call the function from my CustomCacheManager class.

### Reproduction steps

This is my CustomCacheManager like your example :

```
class CustomCacheManager extends BaseCacheManager {
static const key = "customCache";

static CustomCacheManager _instance;

factory CustomCacheManager() {
if (_instance == null) {
_instance = new CustomCacheManager._();
}
return _instance;
}

CustomCacheManager._() : super(key,
maxAgeCacheObject: Duration(days: 2),
maxNrOfCacheObjects: 20);

@override
Future getFilePath() async {
var directory = await getTemporaryDirectory();
return join(directory.path, key);
}

Future removePicture(String file) async {
await removeFile(file);
}

Future clearCustomCache() async {
await emptyCache();
}
}
```
I am trying to remove the picture like that :
```
retryTakePicture(String imageToRemove) async {
await _customCacheManager.removePicture(imageToRemove).then((_) {
***some code***
});
}
```

So when I retry to take the picture, the file is not removed from the cache so I got CameraException :
```CameraException(fileExists, File at path /data/user/0/*package_name*/cache/customCache/*file_name*' already exists. Cannot overwrite.)```

I don't know if I misunderstood the purpose of the removeFile method or if it's a bug.

And I have the same problem with `emptyCache()`.

### Configuration

**Version:** 1.2.2

**Platform:**
No problem on iOS

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

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

Hướng nghiên cứu

Start with the BaseCacheManager entry points removeFile and emptyCache, using the CustomCacheManager example in the issue to reproduce the behavior on Android. Check the cache path under the app's temporary directory and verify that removing one file and clearing the cache both complete before retryTakePicture runs. Done means the existing file is gone and the camera no longer reports fileExists.

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
mobile-dev
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
45/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.