From 78ff5a6b00be0a830a9dec4efaf042f5c18c276c Mon Sep 17 00:00:00 2001 From: Pigway Date: Tue, 6 Oct 2026 22:18:56 +0800 Subject: [PATCH] Correct unknown upload reconciliation and allow longer upload response --- pigway_frame_flow/display/service.py | 11 +++++++---- pigway_frame_flow/drivers/kokonna/client.py | 2 +- tests/test_display.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pigway_frame_flow/display/service.py b/pigway_frame_flow/display/service.py index f033fdb..d0f3337 100644 --- a/pigway_frame_flow/display/service.py +++ b/pigway_frame_flow/display/service.py @@ -703,6 +703,11 @@ class DisplayService: device = driver.device(refresh=True) images = driver.images() expected = (op["result"] or {}).get("image_id") + confirmed = ( + bool(expected) + and expected == device.current_content.id + and device.current_content.synced + ) resolved = op["status"] != "UNKNOWN" if op["status"] == "UNKNOWN" and ( acknowledge @@ -715,7 +720,7 @@ class DisplayService: # Acknowledge releases the block; it never resends a write. self.update( id, - "COMPLETED" if expected == device.current_content.id else "FAILED", + "COMPLETED" if confirmed else "FAILED", {"image_id": device.current_content.id}, ) resolved = True @@ -727,9 +732,7 @@ class DisplayService: device_id=op["device_id"], action="reconcile", ), - "CONFIRMED" - if expected == device.current_content.id - else "ACKNOWLEDGED", + "CONFIRMED" if confirmed else "ACKNOWLEDGED", ) return dict( operation_id=id, diff --git a/pigway_frame_flow/drivers/kokonna/client.py b/pigway_frame_flow/drivers/kokonna/client.py index 88b1345..55911a5 100644 --- a/pigway_frame_flow/drivers/kokonna/client.py +++ b/pigway_frame_flow/drivers/kokonna/client.py @@ -48,7 +48,7 @@ class SafeTransport: "Content-Type": "application/json", }, json=None if binary else payload or {}, - timeout=(5, 30), + timeout=(5, 120 if endpoint == "/upload" else 30), allow_redirects=False, ) except requests.RequestException: diff --git a/tests/test_display.py b/tests/test_display.py index 98f8b0a..bd5fd5a 100644 --- a/tests/test_display.py +++ b/tests/test_display.py @@ -86,6 +86,7 @@ def test_no_retry_unknown(service): assert service.process_one() is False assert service.reconcile(id)["resolved"] is False assert service.reconcile(id, True)["resolved"] is True + assert service.operation(id)["status"] == "FAILED" def test_restart_preserves_override(service):