mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 05:21:36 +00:00
Handle missing file attachments in message processing (#587)
Some checks are pending
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Some checks are pending
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
parent
81bc0f39e8
commit
f8491e61a5
@ -156,29 +156,43 @@ public sealed class ContentText : IContent
|
|||||||
|
|
||||||
if(this.FileAttachments.Count > 0)
|
if(this.FileAttachments.Count > 0)
|
||||||
{
|
{
|
||||||
// Check Pandoc availability once before processing file attachments
|
// Filter out files that no longer exist
|
||||||
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
var existingFiles = this.FileAttachments.Where(File.Exists).ToList();
|
||||||
|
|
||||||
if (!pandocState.IsAvailable)
|
// Log warning for missing files
|
||||||
LOGGER.LogWarning("File attachments could not be processed because Pandoc is not available.");
|
var missingFiles = this.FileAttachments.Except(existingFiles).ToList();
|
||||||
else if (!pandocState.CheckWasSuccessful)
|
if (missingFiles.Count > 0)
|
||||||
LOGGER.LogWarning("File attachments could not be processed because the Pandoc version check failed.");
|
foreach (var missingFile in missingFiles)
|
||||||
else
|
LOGGER.LogWarning("File attachment no longer exists and will be skipped: '{MissingFile}'", missingFile);
|
||||||
|
|
||||||
|
// Only proceed if there are existing files
|
||||||
|
if (existingFiles.Count > 0)
|
||||||
{
|
{
|
||||||
sb.AppendLine();
|
// Check Pandoc availability once before processing file attachments
|
||||||
sb.AppendLine("The following files are attached to this message:");
|
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
||||||
foreach(var file in this.FileAttachments)
|
|
||||||
|
if (!pandocState.IsAvailable)
|
||||||
|
LOGGER.LogWarning("File attachments could not be processed because Pandoc is not available.");
|
||||||
|
else if (!pandocState.CheckWasSuccessful)
|
||||||
|
LOGGER.LogWarning("File attachments could not be processed because the Pandoc version check failed.");
|
||||||
|
else
|
||||||
{
|
{
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine("---------------------------------------");
|
sb.AppendLine("The following files are attached to this message:");
|
||||||
sb.AppendLine($"File path: {file}");
|
foreach(var file in existingFiles)
|
||||||
sb.AppendLine("File content:");
|
{
|
||||||
sb.AppendLine("````");
|
sb.AppendLine();
|
||||||
sb.AppendLine(await Program.RUST_SERVICE.ReadArbitraryFileData(file, int.MaxValue));
|
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();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user