From 27ecd634d372ea5ee0c5edd4c631c073764fb33d Mon Sep 17 00:00:00 2001 From: John Lambert Date: Wed, 15 Jan 2025 10:47:50 -0500 Subject: [PATCH 1/3] Fix for #601 - no pretranslations written --- .../src/Serval.Machine.Shared/Services/MessageOutboxService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } From 8c0cfbceea52b080f01f08c8724497da30b62892 Mon Sep 17 00:00:00 2001 From: John Lambert Date: Wed, 15 Jan 2025 11:27:26 -0500 Subject: [PATCH 2/3] Better form --- .../Services/MessageOutboxService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs index 6a6e2407..7d251b8e 100644 --- a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs +++ b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs @@ -84,10 +84,10 @@ await _outboxes.UpdateAsync( string filePath = Path.Combine(_options.CurrentValue.OutboxDir, outboxMessage.Id); try { - await using Stream fileStream = _fileSystem.OpenWrite(filePath); - await contentStream.CopyToAsync(fileStream, cancellationToken); - await fileStream.FlushAsync(cancellationToken); - await fileStream.DisposeAsync(); + using (Stream fileStream = _fileSystem.OpenWrite(filePath)) + { + await contentStream.CopyToAsync(fileStream, cancellationToken); + } await _messages.InsertAsync(outboxMessage, cancellationToken: cancellationToken); return outboxMessage.Id; } From 8fd113e0ef2a62c5d6b749970c775a2563d38804 Mon Sep 17 00:00:00 2001 From: John Lambert Date: Wed, 15 Jan 2025 13:55:13 -0500 Subject: [PATCH 3/3] await using --- .../src/Serval.Machine.Shared/Services/MessageOutboxService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs index 7d251b8e..01ade34c 100644 --- a/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs +++ b/src/Machine/src/Serval.Machine.Shared/Services/MessageOutboxService.cs @@ -84,7 +84,7 @@ await _outboxes.UpdateAsync( string filePath = Path.Combine(_options.CurrentValue.OutboxDir, outboxMessage.Id); try { - using (Stream fileStream = _fileSystem.OpenWrite(filePath)) + await using (Stream fileStream = _fileSystem.OpenWrite(filePath)) { await contentStream.CopyToAsync(fileStream, cancellationToken); }