LocalPacks

class LocalPacks(root: Path, delayMillis: Long = 0, failEvery: Int = 0) : PackSource(source)

Packs read from root/<packId>/ on disk, for debug builds and tests. A fetch waits delayMillis (showing Downloading) and every failEvery-th fetch fails as NoNetwork (0 never fails). Like a store, nothing is readable before a fetch; remove forgets the fetch and never deletes the files. Release builds never use it.

Constructors

Link copied to clipboard
constructor(root: Path, delayMillis: Long = 0, failEvery: Int = 0)

Functions

Link copied to clipboard
open suspend override fun fetch(packId: String): PackState

Starts or resumes the download and suspends until the state isSettled. Cancelling cancels the download.

Link copied to clipboard
open suspend override fun readBytes(packId: String, path: String): ByteArray?

A file of a ready pack, or null when the pack is not ready or has no such file.

Link copied to clipboard
open suspend override fun remove(packId: String)

Frees the pack's space; the next fetch downloads it again.

Link copied to clipboard
open override fun state(packId: String): Flow<PackState>

The pack's state; the first value is read from the store, never assumed.