ModelDownloader

class ModelDownloader(files: List<ModelFile>, url: (ModelFile) -> String, dir: File, token: String?)(source)

Fetches a model's files into its folder. Each file downloads to <name>.part, resuming with an HTTP Range request after any interruption, then must match its SHA-256 before it's renamed into place. Files already in place are skipped, so a rerun only fetches what's missing.

Constructors

Link copied to clipboard
constructor(files: List<ModelFile>, url: (ModelFile) -> String, dir: File, token: String?)

Functions

Link copied to clipboard
suspend fun run(base: Long = 0, total: Long = files.sumOf { it.bytes }, onProgress: (done: Long, total: Long) -> Unit)

base and total place these files' progress within a larger download.