Skip to content

Commit 1ebd0d4

Browse files
authored
Merge pull request #527 from iceljc/master
refine message file save
2 parents 5001dbb + 2997d4a commit 1ebd0d4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/Infrastructure/BotSharp.Core/Files/Services/BotSharpFileService.Conversation.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,16 @@ public bool SaveMessageFiles(string conversationId, string messageId, string sou
188188
var dir = GetConversationFileDirectory(conversationId, messageId, createNewDir: true);
189189
if (!ExistDirectory(dir)) return false;
190190

191-
try
191+
for (int i = 0; i < files.Count; i++)
192192
{
193-
for (int i = 0; i < files.Count; i++)
193+
var file = files[i];
194+
if (string.IsNullOrEmpty(file.FileData))
194195
{
195-
var file = files[i];
196-
if (string.IsNullOrEmpty(file.FileData))
197-
{
198-
continue;
199-
}
196+
continue;
197+
}
200198

199+
try
200+
{
201201
var (_, bytes) = GetFileInfoFromData(file.FileData);
202202
var subDir = Path.Combine(dir, source, $"{i + 1}");
203203
if (!ExistDirectory(subDir))
@@ -213,14 +213,14 @@ public bool SaveMessageFiles(string conversationId, string messageId, string sou
213213
Thread.Sleep(100);
214214
}
215215
}
216-
217-
return true;
218-
}
219-
catch (Exception ex)
220-
{
221-
_logger.LogWarning($"Error when saving conversation files: {ex.Message}\r\n{ex.InnerException}");
222-
return false;
216+
catch (Exception ex)
217+
{
218+
_logger.LogWarning($"Error when saving message file {file.FileName}: {ex.Message}\r\n{ex.InnerException}");
219+
continue;
220+
}
223221
}
222+
223+
return true;
224224
}
225225

226226

0 commit comments

Comments
 (0)