Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Jun 28, 2024
1 parent 06cb085 commit 5c69aca
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/SIL.Machine.AspNetCore/Services/ServalPlatformOutboxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ await _client.BuildRestartingAsync(
case ServalPlatformMessageMethod.InsertPretranslations:

{
Stream targetPretranslateStream = await _sharedFileService.OpenReadAsync(
using Stream targetPretranslateStream = await _sharedFileService.OpenReadAsync(
$"outbox/{message.Id}",
cancellationToken
);
Expand All @@ -77,23 +77,24 @@ await _client.BuildRestartingAsync(
cancellationToken
)
.OfType<Pretranslation>();
IAsyncEnumerable<InsertPretranslationRequest> requests = pretranslations.Select(
p => new InsertPretranslationRequest
{
EngineId = message.RequestContent!,
CorpusId = p.CorpusId,
TextId = p.TextId,
Refs = { p.Refs },
Translation = p.Translation
}
);

using var call = _client.InsertPretranslations(cancellationToken: cancellationToken);
await foreach (var request in requests)
await foreach (Pretranslation? pretranslation in pretranslations)
{
await call.RequestStream.WriteAsync(request, cancellationToken: cancellationToken);
await call.RequestStream.WriteAsync(
new InsertPretranslationRequest
{
EngineId = message.RequestContent!,
CorpusId = pretranslation.CorpusId,
TextId = pretranslation.TextId,
Refs = { pretranslation.Refs },
Translation = pretranslation.Translation
},
cancellationToken
);
}
await call.RequestStream.CompleteAsync();
await call;
}
break;
case ServalPlatformMessageMethod.IncrementTranslationEngineCorpusSize:
Expand Down

0 comments on commit 5c69aca

Please sign in to comment.