mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 06:01:37 +00:00
Fixed cleanup logic for temporary files
This commit is contained in:
parent
8e82a07a33
commit
3b6d55ca4c
@ -25,10 +25,11 @@ public static class PandocExport
|
||||
|
||||
LOGGER.LogInformation($"The user chose the path '{response.SaveFilePath}' for the Microsoft Word export.");
|
||||
|
||||
var tempMarkdownFilePath = string.Empty;
|
||||
try
|
||||
{
|
||||
var tempMarkdownFile = Guid.NewGuid().ToString();
|
||||
var tempMarkdownFilePath = Path.Combine(Path.GetTempPath(), tempMarkdownFile);
|
||||
tempMarkdownFilePath = Path.Combine(Path.GetTempPath(), tempMarkdownFile);
|
||||
|
||||
// Extract text content from chat:
|
||||
var markdownText = markdownContent switch
|
||||
@ -110,13 +111,16 @@ public static class PandocExport
|
||||
finally
|
||||
{
|
||||
// Try to remove the temp file:
|
||||
try
|
||||
if (!string.IsNullOrWhiteSpace(tempMarkdownFilePath))
|
||||
{
|
||||
File.Delete(tempMarkdownFilePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
LOGGER.LogWarning($"Was not able to delete temporary file: '{tempMarkdownFilePath}'");
|
||||
try
|
||||
{
|
||||
File.Delete(tempMarkdownFilePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
LOGGER.LogWarning($"Was not able to delete temporary file: '{tempMarkdownFilePath}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user