From f06b361fc03c1fa527800cd21e9192da70900ebf Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Mon, 13 Apr 2026 11:51:31 +0100 Subject: [PATCH] Write objects in reverse order instead of root object twice (#470) --- src/Speckle.Sdk/Pipelines/Send/SendPipeline.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Speckle.Sdk/Pipelines/Send/SendPipeline.cs b/src/Speckle.Sdk/Pipelines/Send/SendPipeline.cs index 3ddd4249..55613c6d 100644 --- a/src/Speckle.Sdk/Pipelines/Send/SendPipeline.cs +++ b/src/Speckle.Sdk/Pipelines/Send/SendPipeline.cs @@ -36,28 +36,22 @@ public sealed class SendPipeline : IDisposable _diskStore = diskStore; } - private UploadItem _lastItem; - public async Task Process(Base @base) { var results = _serializer.Serialize(@base).ToArray(); var first = results.First(); - foreach (var item in results) + // .Reverse ensures the root commit object is written last. + foreach (var item in results.Reverse()) { // we're not doing fire and forget here so that we get the backpressure from the uploader await _diskStore.PushAsync(item).ConfigureAwait(false); } - // NOTE: this is important to keep track of. When we serialze an object, we get back a list of objects, with the first one being the original root. - // In the case of the commit root object, this means the last object is not necessarily the root; we therefore need to manually track its existance here - // and ensure it's the last one through in the uploader's stream. See WaitForUpload down below. - _lastItem = first; return first.Reference; } public async Task WaitForUpload() { - await _diskStore.PushAsync(_lastItem).ConfigureAwait(false); using DisposableFile tempFile = await _diskStore.CompleteAsync().ConfigureAwait(false); using Stream fileStreamUpload = new FileStream(