diff --git a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs index bcde1e98..6a6e2407 100644 --- a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs +++ b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs @@ -50,7 +50,6 @@ await _outboxes.UpdateAsync( Content = serializedContent, HasContentStream = false }; - string filePath = Path.Combine(_options.CurrentValue.OutboxDir, outboxMessage.Id); await _messages.InsertAsync(outboxMessage, cancellationToken: cancellationToken); return outboxMessage.Id; } @@ -87,6 +86,8 @@ await _outboxes.UpdateAsync( { await using Stream fileStream = _fileSystem.OpenWrite(filePath); await contentStream.CopyToAsync(fileStream, cancellationToken); + await fileStream.FlushAsync(cancellationToken); + await fileStream.DisposeAsync(); await _messages.InsertAsync(outboxMessage, cancellationToken: cancellationToken); return outboxMessage.Id; }