From 143379dad73bab96a8d94f768609a1c93b9a64c0 Mon Sep 17 00:00:00 2001 From: Katelyn Baker Date: Fri, 13 Jul 2018 18:14:34 +0100 Subject: [PATCH] CORDA-1588 - Add an extra check in the attachment resolution flow to prevent duplicate attachment import if multiple transactions with the same attachment are being resolved at the same time. (#3599) --- .../main/kotlin/net/corda/core/internal/FetchDataFlow.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/net/corda/core/internal/FetchDataFlow.kt b/core/src/main/kotlin/net/corda/core/internal/FetchDataFlow.kt index 867a719949..5c82f5ea53 100644 --- a/core/src/main/kotlin/net/corda/core/internal/FetchDataFlow.kt +++ b/core/src/main/kotlin/net/corda/core/internal/FetchDataFlow.kt @@ -147,7 +147,13 @@ class FetchAttachmentsFlow(requests: Set, override fun maybeWriteToDisk(downloaded: List) { for (attachment in downloaded) { - serviceHub.attachments.importAttachment(attachment.open(), "$P2P_UPLOADER:${otherSideSession.counterparty.name}", null) + with(serviceHub.attachments) { + if (!hasAttachment(attachment.id)) { + importAttachment(attachment.open(), "$P2P_UPLOADER:${otherSideSession.counterparty.name}", null) + } else { + logger.info("Attachment ${attachment.id} already exists, skipping.") + } + } } }