Baseflow / Baseflow/flutter_cache_manager
No exist file after call 'getSingleFile'
- 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 will be downloaded mp3 file from cloud storage.
Then used getSingleFile api and custom cache manager.
```dart
class CustomCacheManager extends BaseCacheManager {
factory CustomCacheManager() => _instance ??= CustomCacheManager._();
CustomCacheManager._()
: super(key,
maxAgeCacheObject: const Duration(days: 30),
maxNrOfCacheObjects: 200);
static const key = 'customCache';
static CustomCacheManager _instance;
@override
Future getFilePath() async {
final directory = await getTemporaryDirectory();
return p.join(directory.path, key);
}
}
```
```dart
final result = [];
final cacheManager = fileStorageRepository.getCacheManager;
for (var voice in voices) {
final file = await cacheManager.getSingleFile(voice.url);
print('${file.path} ${file.existsSync()}'); // file.existsSync() -> false
result.add(file);
}
return result;
```
It correctly get file but sometime file is no exist.
But It succeed if retry for a while.
Is cache setting incorrect or usage getSingleFile api incorrect?
Additional comment, attached error log with audio player in Android.
It occur error when play audio file getting from getSingleFile.
```
E/AudioplayersPlugin(26546): Unexpected error!
E/AudioplayersPlugin(26546): java.lang.RuntimeException: Unable to access resource
E/AudioplayersPlugin(26546): at xyz.luan.audioplayers.WrappedMediaPlayer.setSource(WrappedMediaPlayer.java:289)
E/AudioplayersPlugin(26546): at xyz.luan.audioplayers.WrappedMediaPlayer.setUrl(WrappedMediaPlayer.java:54)
E/AudioplayersPlugin(26546): at xyz.luan.audioplayers.AudioplayersPlugin.handleMethodCall(AudioplayersPlugin.java:65)
E/AudioplayersPlugin(26546): at xyz.luan.audioplayers.AudioplayersPlugin.onMethodCall(AudioplayersPlugin.java:44)
E/AudioplayersPlugin(26546): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/AudioplayersPlugin(26546): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/AudioplayersPlugin(26546): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/AudioplayersPlugin(26546): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AudioplayersPlugin(26546): at android.os.MessageQueue.next(MessageQueue.java:336)
E/AudioplayersPlugin(26546): at android.os.Looper.loop(Looper.java:174)
E/AudioplayersPlugin(26546): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AudioplayersPlugin(26546): at java.lang.reflect.Method.invoke(Native Method)
E/AudioplayersPlugin(26546): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AudioplayersPlugin(26546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AudioplayersPlugin(26546): Caused by: java.io.FileNotFoundException: /data/user/0/com.sample.app/cache/customCache/531acd30-cd4e-11ea-9fe9-5ba2b4995f64.mp3: open failed: ENOENT (No such file or directory)
E/AudioplayersPlugin(26546): at libcore.io.IoBridge.open(IoBridge.java:496)
E/AudioplayersPlugin(26546): at java.io.FileInputStream.(FileInputStream.java:159)
E/AudioplayersPlugin(26546): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1182)
E/AudioplayersPlugin(26546): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1160)
E/AudioplayersPlugin(26546): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1125)
E/AudioplayersPlugin(26546): at xyz.luan.audioplayers.WrappedMediaPlayer.setSource(WrappedMediaPlayer.java:287)
E/AudioplayersPlugin(26546): ... 13 more
E/AudioplayersPlugin(26546): Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
E/AudioplayersPlugin(26546): at libcore.io.Linux.open(Native Method)
E/AudioplayersPlugin(26546): at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
E/AudioplayersPlugin(26546): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
E/AudioplayersPlugin(26546): at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
E/AudioplayersPlugin(26546): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7255)
E/AudioplayersPlugin(26546): at libcore.io.IoBridge.open(IoBridge.java:482)
E/AudioplayersPlugin(26546): ... 18 more
E/MethodChannel#xyz.luan/audioplayers(26546): Failed to handle method call
E/MethodChannel#xyz.luan/audioplayers(26546): java.lang.IllegalArgumentException: Unsupported value: java.lang.RuntimeException: Unable to access resource
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:278)
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:69)
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:236)
E/MethodChannel#xyz.luan/audioplayers(26546): at xyz.luan.audioplayers.AudioplayersPlugin.onMethodCall(AudioplayersPlugin.java:47)
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#xyz.luan/audioplayers(26546): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#xyz.luan/audioplayers(26546): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#xyz.luan/audioplayers(26546): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#xyz.luan/audioplayers(26546): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#xyz.luan/audioplayers(26546): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#xyz.luan/audioplayers(26546): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#xyz.luan/audioplayers(26546): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#xyz.luan/audioplayers(26546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
```
### Expected behavior
Correctly get files.
### Reproduction steps
none
### Configuration
**Version:** 1.4.1
**Platform:**
- [x] :iphone: iOS
- [x] :robot: Android
Hướng dẫn đóng góp
Hướng nghiên cứu
Start by examining BaseCacheManager.getSingleFile and the overridden getFilePath in the reported CustomCacheManager, then reproduce the intermittent case on Android using the supplied audio-player failure. Check whether the returned path still exists before playback and compare the cache manager result with the ENOENT path in the log. Done means getSingleFile consistently returns an existing playable file.
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100