From cbcd22f09c47c421bda665a9e3a2259f815f595c Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 21 Aug 2026 11:54:48 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20retry=20=D0=BA=D0=BE=D0=BD=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=82=D0=B0=D1=86=D0=B8=D0=B8=20(2=20=D0=BF=D0=BE=D0=BF?= =?UTF-8?q?=D1=8B=D1=82=D0=BA=D0=B8)=20=D0=BF=D1=80=D0=B8=20failed/error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - polling-цикл: при status failed/error — retry (до 2 раз) - логирование каждого retry - после исчерпания retry — текущее поведение (кнопка 'Перезаказать') --- .../binom/viewmate/phone/ui/DetailsScreen.kt | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt b/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt index a73f5e5..e78ad11 100644 --- a/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt +++ b/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt @@ -85,10 +85,34 @@ fun DetailsScreen( mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() loading = false - while (mirrorStatus?.status == "processing" || mirrorStatus?.status == "queued") { - delay(3_000) - mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() - mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() + var retryCount = 0 + while (true) { + when (mirrorStatus?.status) { + "processing", "queued" -> { + delay(3_000) + mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() + mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() + retryCount = 0 + } + "done" -> { + break + } + "failed", "error" -> { + if (retryCount < 2) { + retryCount++ + log("mirror", "конвертация упала, retry $retryCount/2 для ${item.Id}") + runCatching { app.mirror.createMirror(item.Id) } + .onSuccess { refreshKey++ } + .onFailure { e -> log("mirror", "retry $retryCount не удался: ${e.message}") } + delay(5_000) + } else { + break + } + } + else -> { + break + } + } } }