Skip to content

Kotlin: Retry an attachment

attachmentRetry(reference) 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#

// app/src/main/kotlin/com/example/todo/TodoScreen.kt (excerpt)
val retried = kizunasync.attachmentRetry(reference)

Offer retry only on a permanent failure#

// app/src/main/kotlin/com/example/todo/TodoScreen.kt (excerpt)
val status = kizunasync.getStatus(reference)
if (status?.permanent == true) {
    kizunasync.attachmentRetry(reference)
}

Parameters#

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

Returns#

Boolean. 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