voice: opening a screen mid-download no longer deletes the download in progress

This commit is contained in:
Seb3thehacker committed 2026-10-13 17:54:36 -07:00
1 parent 3042e01e75
commit 8b269f4734
1 file changed
+5 -2
@@ -112,9 +112,12 @@ object SpeechModels {
?: if (isReady(context, Model.PARAKEET_LARGE) && !isReady(context, Model.CANARY)) Model.PARAKEET_LARGE.id else Model.CANARY.id
_final.value = Model.entries.firstOrNull { it.id == finalId && it.role == Role.FINAL }
Model.entries.forEach { m -> if (isReady(context, m)) states.getValue(m).value = State.Ready }
// Models an older build offered and this one doesn't: hundreds of MB nobody can use.
// Models an older build offered and this one doesn't: hundreds of MB nobody can use. A
// known model's ".partial" folder is a download that may be running right now; [download]
// clears its own leftovers when it starts.
val known = Model.entries.map { it.id }.toSet()
File(context.filesDir, "speech").listFiles()?.filter { it.isDirectory && it.name !in known }?.forEach {
File(context.filesDir, "speech").listFiles()
?.filter { it.isDirectory && it.name.removeSuffix(".partial") !in known }?.forEach {
GearslipLog.i("speech: removing ${it.name}, no longer offered")
it.deleteRecursively()
}