From 34dd75bb400b77f6ca1db3c1ae794e57dd562cc6 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Tue, 9 Dec 2025 21:44:46 +0100 Subject: [PATCH] Ensure Pandoc availability check before processing files --- app/MindWork AI Studio/Chat/ContentText.cs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/MindWork AI Studio/Chat/ContentText.cs b/app/MindWork AI Studio/Chat/ContentText.cs index d7e0a2a3..fe580398 100644 --- a/app/MindWork AI Studio/Chat/ContentText.cs +++ b/app/MindWork AI Studio/Chat/ContentText.cs @@ -153,20 +153,27 @@ public sealed class ContentText : IContent { var sb = new StringBuilder(); sb.AppendLine(this.Text); - + if(this.FileAttachments.Count > 0) { - sb.AppendLine(); - sb.AppendLine("The following files are attached to this message:"); - foreach(var file in this.FileAttachments) + // Check Pandoc availability once before processing file attachments + var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false); + if (!pandocState.IsAvailable || !pandocState.CheckWasSuccessful) + LOGGER.LogWarning("File attachments could not be processed because Pandoc is not available or the version check failed."); + else { sb.AppendLine(); - sb.AppendLine("---------------------------------------"); - sb.AppendLine($"File path: {file}"); - sb.AppendLine("File content:"); - sb.AppendLine("````"); - sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue)); - sb.AppendLine("````"); + sb.AppendLine("The following files are attached to this message:"); + foreach(var file in this.FileAttachments) + { + sb.AppendLine(); + sb.AppendLine("---------------------------------------"); + sb.AppendLine($"File path: {file}"); + sb.AppendLine("File content:"); + sb.AppendLine("````"); + sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue)); + sb.AppendLine("````"); + } } } return sb.ToString();