Correct unknown upload reconciliation and allow longer upload response

This commit is contained in:
Pigway
2026-10-06 22:18:56 +08:00
parent 557e21ca58
commit 78ff5a6b00
3 changed files with 9 additions and 5 deletions
+7 -4
View File
@@ -703,6 +703,11 @@ class DisplayService:
device = driver.device(refresh=True) device = driver.device(refresh=True)
images = driver.images() images = driver.images()
expected = (op["result"] or {}).get("image_id") 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" resolved = op["status"] != "UNKNOWN"
if op["status"] == "UNKNOWN" and ( if op["status"] == "UNKNOWN" and (
acknowledge acknowledge
@@ -715,7 +720,7 @@ class DisplayService:
# Acknowledge releases the block; it never resends a write. # Acknowledge releases the block; it never resends a write.
self.update( self.update(
id, id,
"COMPLETED" if expected == device.current_content.id else "FAILED", "COMPLETED" if confirmed else "FAILED",
{"image_id": device.current_content.id}, {"image_id": device.current_content.id},
) )
resolved = True resolved = True
@@ -727,9 +732,7 @@ class DisplayService:
device_id=op["device_id"], device_id=op["device_id"],
action="reconcile", action="reconcile",
), ),
"CONFIRMED" "CONFIRMED" if confirmed else "ACKNOWLEDGED",
if expected == device.current_content.id
else "ACKNOWLEDGED",
) )
return dict( return dict(
operation_id=id, operation_id=id,
+1 -1
View File
@@ -48,7 +48,7 @@ class SafeTransport:
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
json=None if binary else payload or {}, json=None if binary else payload or {},
timeout=(5, 30), timeout=(5, 120 if endpoint == "/upload" else 30),
allow_redirects=False, allow_redirects=False,
) )
except requests.RequestException: except requests.RequestException:
+1
View File
@@ -86,6 +86,7 @@ def test_no_retry_unknown(service):
assert service.process_one() is False assert service.process_one() is False
assert service.reconcile(id)["resolved"] is False assert service.reconcile(id)["resolved"] is False
assert service.reconcile(id, True)["resolved"] is True assert service.reconcile(id, True)["resolved"] is True
assert service.operation(id)["status"] == "FAILED"
def test_restart_preserves_override(service): def test_restart_preserves_override(service):