Skip to content

Await store.putFile so cache info is persisted #492 - #518

Open
AzazelSensei wants to merge 1 commit into
Baseflow:developfrom
AzazelSensei:fix/await-putfile-persist
Open

Await store.putFile so cache info is persisted #492#518
AzazelSensei wants to merge 1 commit into
Baseflow:developfrom
AzazelSensei:fix/await-putfile-persist

Conversation

@AzazelSensei

Copy link
Copy Markdown

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

Bug fix

⤵️ What is the current behavior?

putFile, putFileStream, and WebHelper start store.putFile and return without waiting. The file is on disk, but the cache-info row (and its id) may not be written yet.

That matches #492: removeFile after getFileStream can no-op because CacheObject.id is still null, and a crash right after download can drop the entry.

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

Those paths now await persist. After they complete, the store has the object and an id, so a follow-up removeFile actually deletes it.

💥 Does this PR introduce a breaking change?

No. Callers already treat these as Futures. They just wait a bit longer for the existing database write.

🐛 Recommendations for testing

flutter test in flutter_cache_manager. New cases delay store.putFile and fail if the caller returns early.

📝 Links to relevant issues/docs

Fixes #492

🤔 Checklist before submitting

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

putFile, putFileStream, and downloads started persist without waiting.
After those calls returned, CacheObject.id could still be null, so
removeFile skipped the entry and a process exit could lose the info.

Fixes Baseflow#492
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

Successfully merging this pull request may close these issues.

CacheManager: does not wait for data to be persisted. Potential consistency issue

1 participant