fix(core): eliminate background_downloader temp-file leak + deterministic task IDs (#383)#384
Merged
Merged
Conversation
…der temps (#383) - Single SmartDownloader.downloadGroup constant; route all 4 group sites through it (three used the stale 'flutter_gemma_downloads' literal → cleanup/resume no-op). - resumeFromBackground() + gated init-time sweep of orphaned filesDir temps. - Pin background_downloader ^9.5.6; bump flutter_gemma 1.3.1.
…nt scan; safe test cleanup (#383)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Failed / cancelled / process-killed large-file model downloads leaked multi-GB
background_downloadertemp files (com.bbflight.background_downloader<rand>) in AndroidfilesDir— persistent internal storage the OS never reclaims. Reported in #383 with an exceptionally detailed source-level breakdown by @alan-insam. Fixes all five findings plus the migration needed to make the task-ID change regression-free.Changes
SmartDownloader.downloadGroupconstant; every cleanup / resume call site routed through it (three used the staleflutter_gemma_downloadsliteral ≠ thesmart_downloadsgroup downloads run under — the leak amplifier).sha256of the stableTask.splittriple (baseDirectory / directory / filename), nothashCodeand not the URL. Stable across process restarts, signed-URL rotation, and iOS app-container UUID churn.getOrphanedFiles()now scansfilesDirforcom.bbflight.background_downloader*temps (flaggedisDownloadFragment);cleanupStorage()deletes them.resume()on a recovered paused task instead of stalling until timeout.reset();performCleanupwhole-group,_cleanupAllTasksOfTypetype-scoped.Anti-regression migration
Legacy resume records written by a pre-1.3.1 version are reconciled and purged at startup before the reclaim gate — a
resumeFromBackground()-materialized paused record no longer wedges it — and the blanket sweep only skips when a task is genuinely running (nativeRunningIds = allTasks − pausedTasks), with a 10-min mtime guard against a just-rescheduled download.Behaviour notes
resumeFromBackground().Platform.isAndroid-gated; iOS/macOS/web unaffected (the id-scheme change on iOS is a net improvement — stable across container-UUID rotation).Verification
flutter analyze0 errors/warnings,flutter test470/470,flutter build webclean.--releaseall build clean.background_downloaderstorage.Targets
flutter_gemma1.3.1. Pinsbackground_downloader ^9.5.6.Fixes #383