withContext

abstract suspend fun <R> withContext(action: suspend (context: AttachmentContext) -> R): R

Executes a callback with an exclusive lock on all attachment operations. This helps prevent race conditions between different updates.