Skip to content

Swift: Retry an attachment

attachmentRetry(_:) forgives a permanently failed attachment's transfer budget: the row returns to queued with its attempt count cleared, so the next drive claims it again.

Examples#

Basic#

// TodoApp/AttachmentView.swift (excerpt)
import KizunaSync

let retried = try await kizunasync.attachmentRetry(reference)

Offer retry only on a permanent failure#

// TodoApp/AttachmentView.swift (excerpt)
import KizunaSync

if let status = try await kizunasync.getStatus(reference), status.permanent {
  _ = try await kizunasync.attachmentRetry(reference)
}

Parameters#

NameTypeRequiredDescription
referenceStringYesThe value stored in the row's attachment column, as Attach a file produced it.

Returns#

Bool. true when a row carried the reference, false when none did.

Errors#

CodeCondition
STOREThe row could not be written.
ENGINE_UNAVAILABLEThe bridge answered with an envelope carrying no code, which is not a gradeable failure.
ENGINE_UNAVAILABLEThe client has no engine because Initializing has not run.

Notes#

Retrying clears every trace of the spent budget: state returns to queued, permanent to false, and the attempt count to zero, so the row reads exactly like one that has never been driven. It does nothing to a row that is merely failed and still retryable; the next scheduled drive already claims that one on its own. Reach for this only after the budget is spent, which Get attachment status reports as permanent: true; that budget is attachmentAttempts in Initializing, five attempts by default.

This method reaches the kernel through the same JSON-RPC call every typed method uses underneath; it behaves like any other client method and raises the same KizunaSyncError.engine.

Found a problem? Edit this page on GitHub