Baseflow / Baseflow/flutter_cache_manager
CacheManager saves files with the same path
- Langage dominant
- Dart
- Étoiles
- 809
- Forks
- 510
- Merge moyen
- 6 min
- PR mergées (30 j)
- 1
Description
## 🐛 Bug Report
Scheduled file cleanup on CachedNetworkImage throws `FileSystemException: Cannot delete file`. [Issue](https://github.com/Baseflow/flutter_cached_network_image/issues/335)
After research, it turned out that different images are recorded along the same path. This happens because relativePath encoding uses Uuid().v1() , which uses DateTime.now() , which causes our error when loading a lot of files at the same time.
To solve this problem, changing the path encoding in _flutter_cache_manager-3.3.0/lib/src/cache_manager.dart_ `putFile` and `putFileStream` should help. for example, change **v1** to **v4**, which uses a more random encoding
```
> cacheObject ??= CacheObject(
> url,
> key: key,
> relativePath: '${const Uuid().v1()}.$fileExtension',
> validTill: DateTime.now().add(maxAge),
> );
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Read flutter_cache_manager-3.3.0/lib/src/cache_manager.dart, focusing on putFile and putFileStream and how relativePath is encoded. Confirm that concurrent image writes no longer receive the same path, and that scheduled cleanup can delete the resulting files without a FileSystemException.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- dart, flutter
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100