Baseflow / Baseflow/flutter_cache_manager

CacheManager saves files with the same path

Open
#397 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
809
Forks
510
Avg merge
6m
Merged PRs (30d)
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),
> );
```

Contributor guide

Open the contributing guide

Research direction

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.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.