Repository navigation
Conversation
rickdijk
left a comment
There was a problem hiding this comment.
Please add a test that two managers with different buckets get different cache keys / file services.
| _retryOptions = retryOptions; | ||
| return _instance; | ||
| final cacheKey = bucket ?? defaultKey; | ||
| if (_instances.containsKey(cacheKey)) { |
There was a problem hiding this comment.
When an instance already exists, a new retryOptions argument is silently ignored. Worth documenting, or only accepting options on first create.
|
|
| _bucket = bucket; | ||
| _retryOptions = retryOptions; | ||
| return _instance; | ||
| final cacheKey = bucket ?? key; |
There was a problem hiding this comment.
Important: the raw bucket name is now the Config cache key, and that key becomes both the sqflite/JSON database name and the cache directory name under the app's temp dir. A bucket whose name matches another cache manager's key in the app (for example libCachedImageData, or firebaseCache itself) shares that manager's database and files, and bucket: '' gives key '', so the files land in the temp dir root and the database is named .db. Users who already passed bucket: also find their cache under a new name and the old firebaseCache entries left behind.
Fix: namespace the key, for example:
| final cacheKey = bucket ?? key; | |
| final cacheKey = bucket == null ? key : '${key}_$bucket'; |
(and update the test expectations to match).
| }); | ||
| }); | ||
|
|
||
| tearDown(() { |
There was a problem hiding this comment.
Nit (optional): _instances is a static cache that outlives each test, but this tearDown deletes the temp directory those instances were built against. A second test that calls FirebaseCacheManager(bucket: 'bucket-a') gets the cached instance whose path_provider directory is gone, so it fails or writes outside the mock. Fix: use unique bucket names per test, or add a @visibleForTesting way to clear _instances and call it here.
| static String? _bucket; | ||
| static final Map<String, FirebaseCacheManager> _instances = {}; | ||
|
|
||
| factory FirebaseCacheManager({RetryOptions? retryOptions, String? bucket}) { |
There was a problem hiding this comment.
Nit (optional): the factory now returns one shared instance per bucket, and retryOptions only takes effect on the first call for that bucket; later calls with different options get the existing instance unchanged. Neither is documented. AGENTS.md asks for "Public API documented with /// doc comments where applicable". Fix: add a /// comment on the factory that says both.
rickdijk
left a comment
There was a problem hiding this comment.
| Criterion | Verdict | Reason |
|---|---|---|
| Adds real value | pass | Apps reading from more than one bucket got object-not-found because every instance shared the first bucket. |
| Really fixes it | pass | One instance per bucket, built from its own arguments; the new test fails on main and passes here. |
| Breaks something | concern | Public API is unchanged, but the bucket name is now the raw cache key (see the inline comment on the factory). |
| Version bump ready | fail | pubspec.yaml is still 2.1.4 with no CHANGELOG entry. |
| Covered by tests | pass | returns separate instances per bucket covers keys and file services; ran locally, passes. |
| Contribution guidelines | concern | PR description is from the old template. |
Recommendation: close to mergeable. Namespace the cache key and add the version bump; the rest is optional.
- Version bump missing. This fix ships in the published package, so it needs
version: 2.1.5influtter_cache_manager_firebase/pubspec.yamland a matching## [2.1.5] - 2026-12-01entry at the top of itsCHANGELOG.md(for example* Fixes FirebaseCacheManager reusing the first bucket for every instance). 2.2.0 is already claimed by two other open PRs, so 2.1.5 is the free patch number. Per AGENTS.md a maintainer can add this while merging if you prefer. - PR description. It still uses the old template: the checklist says "Rebased onto current develop" and lacks the "Version bumped and dated CHANGELOG entry added" item, the body still says it updates packages (it no longer does), and "Recommendations for testing" can now point to the new unit test.
- The earlier change request for a test is met by
FirebaseCacheManager returns separate instances per bucket.
🤖 Generated with Claude Code
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
This fixes an issue in which a subsequent FirebaseCacheManager instance cannot load or upload files correctly because the bucket name was set and cached in the first FirebaseCacheManager instance.
It also updates packages to latest versions.
In my case when I try to read a file from another bucket I see error " [firebase_storage/object-not-found] No object exists at the desired reference." although the file is there.
🆕 What is the new behavior (if this is a feature change)?
If we're initializing a FirebaseCacheManager with a new instance, it makes sure to use another cache key so that files from the other bucket can be read.
💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
Hmm, not sure
📝 Links to relevant issues/docs
🤔 Checklist before submitting