diff --git a/src/Infrastructure/BotSharp.Core/Files/Services/BotSharpFileService.Conversation.cs b/src/Infrastructure/BotSharp.Core/Files/Services/BotSharpFileService.Conversation.cs index ba01ce9d3..a3908b2b1 100644 --- a/src/Infrastructure/BotSharp.Core/Files/Services/BotSharpFileService.Conversation.cs +++ b/src/Infrastructure/BotSharp.Core/Files/Services/BotSharpFileService.Conversation.cs @@ -188,16 +188,16 @@ public bool SaveMessageFiles(string conversationId, string messageId, string sou var dir = GetConversationFileDirectory(conversationId, messageId, createNewDir: true); if (!ExistDirectory(dir)) return false; - try + for (int i = 0; i < files.Count; i++) { - for (int i = 0; i < files.Count; i++) + var file = files[i]; + if (string.IsNullOrEmpty(file.FileData)) { - var file = files[i]; - if (string.IsNullOrEmpty(file.FileData)) - { - continue; - } + continue; + } + try + { var (_, bytes) = GetFileInfoFromData(file.FileData); var subDir = Path.Combine(dir, source, $"{i + 1}"); if (!ExistDirectory(subDir)) @@ -213,14 +213,14 @@ public bool SaveMessageFiles(string conversationId, string messageId, string sou Thread.Sleep(100); } } - - return true; - } - catch (Exception ex) - { - _logger.LogWarning($"Error when saving conversation files: {ex.Message}\r\n{ex.InnerException}"); - return false; + catch (Exception ex) + { + _logger.LogWarning($"Error when saving message file {file.FileName}: {ex.Message}\r\n{ex.InnerException}"); + continue; + } } + + return true; }