Make calendar outbox invariants explicit
This commit is contained in:
@@ -980,7 +980,9 @@ def execute_calendar_outbox_operation(
|
|||||||
)
|
)
|
||||||
return operation
|
return operation
|
||||||
except CalDAVPreconditionFailed as exc:
|
except CalDAVPreconditionFailed as exc:
|
||||||
assert client is not None
|
if client is None:
|
||||||
|
_fail_operation(session, operation=operation, source=source, error=exc)
|
||||||
|
return operation
|
||||||
try:
|
try:
|
||||||
matched, remote_etag = _remote_matches_operation(client, operation)
|
matched, remote_etag = _remote_matches_operation(client, operation)
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -1142,7 +1144,8 @@ def retry_calendar_outbox_operation(
|
|||||||
unavailable_reason = _operation_source_unavailable_reason(operation, source)
|
unavailable_reason = _operation_source_unavailable_reason(operation, source)
|
||||||
if unavailable_reason:
|
if unavailable_reason:
|
||||||
raise ValueError(unavailable_reason)
|
raise ValueError(unavailable_reason)
|
||||||
assert source is not None
|
if source is None:
|
||||||
|
raise RuntimeError("Calendar outbox source availability invariant was violated")
|
||||||
operation.status = "pending"
|
operation.status = "pending"
|
||||||
operation.attempt_count = 0
|
operation.attempt_count = 0
|
||||||
operation.available_at = utcnow()
|
operation.available_at = utcnow()
|
||||||
@@ -1186,7 +1189,8 @@ def reconcile_calendar_outbox_operation(
|
|||||||
unavailable_reason = _operation_source_unavailable_reason(operation, source)
|
unavailable_reason = _operation_source_unavailable_reason(operation, source)
|
||||||
if unavailable_reason:
|
if unavailable_reason:
|
||||||
raise ValueError(unavailable_reason)
|
raise ValueError(unavailable_reason)
|
||||||
assert source is not None
|
if source is None:
|
||||||
|
raise RuntimeError("Calendar outbox source availability invariant was violated")
|
||||||
if client_factory is None:
|
if client_factory is None:
|
||||||
from govoplan_calendar.backend.service import caldav_client_for_source
|
from govoplan_calendar.backend.service import caldav_client_for_source
|
||||||
|
|
||||||
@@ -1248,7 +1252,8 @@ def discard_calendar_outbox_operation(
|
|||||||
source is None or source.tenant_id != operation.tenant_id
|
source is None or source.tenant_id != operation.tenant_id
|
||||||
):
|
):
|
||||||
raise ValueError(unavailable_reason)
|
raise ValueError(unavailable_reason)
|
||||||
assert source is not None
|
if source is None:
|
||||||
|
raise RuntimeError("Calendar outbox source availability invariant was violated")
|
||||||
now = utcnow()
|
now = utcnow()
|
||||||
unresolved_chain = (
|
unresolved_chain = (
|
||||||
session.query(CalendarOutboxOperation)
|
session.query(CalendarOutboxOperation)
|
||||||
|
|||||||
Reference in New Issue
Block a user