You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
MagicImage draws a network image from a copy kept on the device.MagicImage.of(url, {fallback, cacheWidth}) answers an ImageProvider that reads the image from the images storage disk when it is held and fetches it once when it is not, so a poster is a request the first time and never again, across launches. A fallback address is the stand-in: it draws at once when held, the address replaces it when it lands, and when the address cannot be fetched the fallback is fetched and stays, with the address asked again after retryAfter. MagicImageCache owns the fetch and the retry window (five minutes by default), shares one request between two draws of a URL, trims the folder to 300 MiB least recently used first on the first use of a launch and again after a quarter of the cap has been written, and has clear(). MagicImageStore is the folder, files named by the SHA-1 of the URL with atomic writes, and MagicImageWire is the dart:io fetch: http and https only, a JPEG, PNG, GIF or WebP body of at most 8 MiB, timeouts, and failures that never name the address. A key that failed, or a stand-in that outlived the retry window (noted per key, so the same address at another cacheWidth retries too), is dropped from the memory cache so the next resolve loads again, and bytes that pass the signature check but do not decode are refused for the retry window instead of downloaded on every resolve. A fetched image the disk will not keep (a full disk) is drawn from memory and not held against the host: the cache throws a MagicImageNotStored carrying the bytes. clear() empties the folder and keeps the root, so the backup exclusion of the disk survives it. On the web MagicImage.of answers a NetworkImage, and MagicImageCache.instance.clear() and MagicImageException exist there so shared sign-out code compiles. Declare the disk in the app's filesystems config with 'exclude_from_backup': true (defaultFilesystemsConfig carries the entry, which Magic.init does not merge by itself); a disk that is not declared or cannot be opened leaves images drawn with no copy kept, with one warning logged. crypto becomes a direct dependency. (lib/src/storage/images/)
A local disk can keep its root out of iCloud and Time Machine backup. Setting 'exclude_from_backup': true on a local disk marks its root directory with kCFURLIsExcludedFromBackupKey on iOS and macOS, through dart:ffi into CoreFoundation, on the first path the disk resolves, whether it created the directory or found it there. Files under the root inherit the exclusion, which suits large downloads the app can fetch again. A refused mark throws a FileSystemException instead of resolving the path. The key defaults to false, and it does nothing on Android, Windows, Linux or the web; a disk without it behaves as before. (lib/src/storage/storage_manager.dart, lib/src/storage/drivers/local/backup_exclusion_io.dart, lib/src/storage/drivers/local/local_adapter_io.dart)