Skip to content

Commit

Permalink
Merge pull request #527 from iceljc/master
Browse files Browse the repository at this point in the history
refine message file save
  • Loading branch information
Oceania2018 authored Jul 3, 2024
2 parents 5001dbb + 2997d4a commit 1ebd0d4
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}


Expand Down

0 comments on commit 1ebd0d4

Please sign in to comment.