Skip to content

Export File System - #431

Merged
martijn00 merged 2 commits into
Baseflow:developfrom
wyyadd:develop
Jul 31, 2024
Merged

Export File System#431
martijn00 merged 2 commits into
Baseflow:developfrom
wyyadd:develop

Conversation

@wyyadd

@wyyaddwyyadd commented Oct 9, 2023

Copy link
Copy Markdown
Contributor

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

feature

⤵️ What is the current behavior?

The FileSystem, IOFileSystem and MemoryCacheSystem can't be imported like code below.

import'package:flutter_cache_manager/flutter_cache_manager.dart';
classCustomCacheManager {
staticconst key ='customCacheKey';
staticCacheManager instance =CacheManager(
Config(
key,
stalePeriod:constDuration(days:7),
maxNrOfCacheObjects:20,
repo:JsonCacheInfoRepository(databaseName: key),
fileSystem:IOFileSystem(key),
fileService:HttpFileService(),
),
);
}

🆕 What is the new behavior (if this is a feature change)?

The FileSystem, IOFileSystem and MemoryCacheSystem can be imported

💥 Does this PR introduce a breaking change?

No

🐛 Recommendations for testing

  1. update pubspec.yaml
flutter_cache_manager:
git:
url: https://github.com/wyyadd/flutter_cache_managerpath: flutter_cache_manager
  1. run flutter pub get
  2. run code below to test
import'package:flutter_cache_manager/flutter_cache_manager.dart';
classCustomCacheManager {
staticconst key ='customCacheKey';
staticCacheManager instance =CacheManager(
Config(
key,
stalePeriod:constDuration(days:7),
maxNrOfCacheObjects:20,
repo:JsonCacheInfoRepository(databaseName: key),
fileSystem:IOFileSystem(key),
fileService:HttpFileService(),
),
);
}

📝 Links to relevant issues/docs

#365

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current develop

Proposal

Please consider using getApplicationCachePath() introduced in path_provider 2.1.0:

Notice that /tmp may be unsuitable for caching on systems with multiple users. For example, run the cached_network_image example first as user A and then as user B on Ubuntu:

PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc555ac0-23b8-11ee-8203-690c79df21e0.jpg' (OS Error: Permission denied, errno = 13)
Another exception was thrown: PathAccessException: Cannot open file, path =
'/tmp/libCachedImageData/dc555ac0-23b8-11ee-8203-690c79df21e0.jpg' (OS Error: Permission denied, errno = 13)
flutter: CacheManager: Failed to download file from https://notAvalid.uri with error:
ClientException with SocketException: Failed host lookup: 'notavalid.uri' (OS Error: No address associated with hostname, errno = -5), uri=https://notavalid.uri
flutter: CacheManager: Failed to download file from https://via.placeholder.com/300x150 with error:
PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc854460-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
flutter: CacheManager: Failed to download file from https://via.placeholder.com/200x150 with error:
PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc854461-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
flutter: CacheManager: Failed to download file from https://via.placeholder.com/350x200 with error:
PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc854462-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
Another exception was thrown: PathAccessException: Cannot open file, path =
'/tmp/libCachedImageData/dc854461-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
flutter: CacheManager: Failed to download file from https://via.placeholder.com/350x150 with error:
PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc856b70-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
flutter: CacheManager: Failed to download file from https://via.placeholder.com/300x300 with error:
PathAccessException: Cannot open file, path = '/tmp/libCachedImageData/dc856b71-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
Another exception was thrown: PathAccessException: Cannot open file, path =
'/tmp/libCachedImageData/dc856b70-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)
Another exception was thrown: PathAccessException: Cannot open file, path =
'/tmp/libCachedImageData/dc856b71-23b8-11ee-8203-690c79df21e0.png' (OS Error: Permission denied, errno = 13)

For flutter desktop, it would be better to use getApplicationCacheDirectory() instead of getTemporaryDirectory() to create directory.
Relevant issue: #416

@MichalNemec

Copy link
Copy Markdown

why is this not merged already, it has been quite some time.

@slaci

Copy link
Copy Markdown

Without this it is not even possible to create a CacheManager object properly 🙃

@martijn00
martijn00 merged commit c3fce5b into Baseflow:developJul 31, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@wyyadd@MichalNemec@slaci@martijn00