mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 19:41:36 +00:00
Handle missing file attachments in message processing
This commit is contained in:
parent
81bc0f39e8
commit
681d041f48
@ -155,6 +155,18 @@ public sealed class ContentText : IContent
|
|||||||
sb.AppendLine(this.Text);
|
sb.AppendLine(this.Text);
|
||||||
|
|
||||||
if(this.FileAttachments.Count > 0)
|
if(this.FileAttachments.Count > 0)
|
||||||
|
{
|
||||||
|
// Filter out files that no longer exist
|
||||||
|
var existingFiles = this.FileAttachments.Where(File.Exists).ToList();
|
||||||
|
|
||||||
|
// Log warning for missing files
|
||||||
|
var missingFiles = this.FileAttachments.Except(existingFiles).ToList();
|
||||||
|
if (missingFiles.Count > 0)
|
||||||
|
foreach (var missingFile in missingFiles)
|
||||||
|
LOGGER.LogWarning("File attachment no longer exists and will be skipped: '{MissingFile}'", missingFile);
|
||||||
|
|
||||||
|
// Only proceed if there are existing files
|
||||||
|
if (existingFiles.Count > 0)
|
||||||
{
|
{
|
||||||
// Check Pandoc availability once before processing file attachments
|
// Check Pandoc availability once before processing file attachments
|
||||||
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
var pandocState = await Pandoc.CheckAvailabilityAsync(Program.RUST_SERVICE, showMessages: true, showSuccessMessage: false);
|
||||||
@ -167,7 +179,7 @@ public sealed class ContentText : IContent
|
|||||||
{
|
{
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine("The following files are attached to this message:");
|
sb.AppendLine("The following files are attached to this message:");
|
||||||
foreach(var file in this.FileAttachments)
|
foreach(var file in existingFiles)
|
||||||
{
|
{
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
sb.AppendLine("---------------------------------------");
|
sb.AppendLine("---------------------------------------");
|
||||||
@ -179,6 +191,8 @@ public sealed class ContentText : IContent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user