mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 14:21:36 +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.");
|
LOGGER.LogInformation($"The user chose the path '{response.SaveFilePath}' for the Microsoft Word export.");
|
||||||
|
|
||||||
|
var tempMarkdownFilePath = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tempMarkdownFile = Guid.NewGuid().ToString();
|
var tempMarkdownFile = Guid.NewGuid().ToString();
|
||||||
var tempMarkdownFilePath = Path.Combine(Path.GetTempPath(), tempMarkdownFile);
|
tempMarkdownFilePath = Path.Combine(Path.GetTempPath(), tempMarkdownFile);
|
||||||
|
|
||||||
// Extract text content from chat:
|
// Extract text content from chat:
|
||||||
var markdownText = markdownContent switch
|
var markdownText = markdownContent switch
|
||||||
@ -110,13 +111,16 @@ public static class PandocExport
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Try to remove the temp file:
|
// Try to remove the temp file:
|
||||||
try
|
if (!string.IsNullOrWhiteSpace(tempMarkdownFilePath))
|
||||||
{
|
{
|
||||||
File.Delete(tempMarkdownFilePath);
|
try
|
||||||
}
|
{
|
||||||
catch
|
File.Delete(tempMarkdownFilePath);
|
||||||
{
|
}
|
||||||
LOGGER.LogWarning($"Was not able to delete temporary file: '{tempMarkdownFilePath}'");
|
catch
|
||||||
|
{
|
||||||
|
LOGGER.LogWarning($"Was not able to delete temporary file: '{tempMarkdownFilePath}'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user