From a68c76979d646fa90a24bff3457be2da0c371f0a Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Wed, 30 Aug 2023 11:00:11 -0700 Subject: [PATCH] swift: flush writer buffer when closing a chunk (#960) ### Public-Facing Changes Swift: data is now properly sent to the writer each time a chunk is closed. ### Description --- swift/mcap/MCAPWriter.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swift/mcap/MCAPWriter.swift b/swift/mcap/MCAPWriter.swift index 8232b0203b..d120c67053 100644 --- a/swift/mcap/MCAPWriter.swift +++ b/swift/mcap/MCAPWriter.swift @@ -161,6 +161,9 @@ public final class MCAPWriter { } } else { message.serialize(to: &buffer) + if buffer.count >= options.chunkSize { + await _flush() + } } } @@ -219,6 +222,7 @@ public final class MCAPWriter { let chunkStartOffset = _position() chunk.serialize(to: &buffer) + await _flush() let messageIndexStartOffset = _position() var messageIndexOffsets: [ChannelID: UInt64] = [:]