Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheManager saves files with the same path #397

Open
nikitahummus opened this issue Dec 23, 2022 · 2 comments
Open

CacheManager saves files with the same path #397

nikitahummus opened this issue Dec 23, 2022 · 2 comments

Comments

@nikitahummus
Copy link

nikitahummus commented Dec 23, 2022

馃悰 Bug Report

Scheduled file cleanup on CachedNetworkImage throws FileSystemException: Cannot delete file. Issue
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),
>     );
@zhancheng
Copy link

i have tried but not useful @nikitahummus

@nikitahummus
Copy link
Author

nikitahummus commented Jan 9, 2023

I also moved the creation of Uuid() to the final variable and use the same object inside CacheObject when creating the path of it.
And I did the same with the CacheManager in CachedNetworkImage, created CacheManager in static property of class with an image widget and use it without creating a new one each time.

it helped @zhancheng

daegalus/dart-uuid#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants