move Path.GetTempFIleName() to try catch

This commit is contained in:
rootdarkarchon
2023-01-17 01:30:37 +01:00
parent 8913798870
commit eb42079e85

View File

@@ -11,6 +11,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Utility;
using LZ4;
using MareSynchronos.API;
using MareSynchronos.Utils;
@@ -123,9 +124,10 @@ public partial class ApiController
}
}
var fileName = "";
try
{
var fileName = Path.GetTempFileName();
fileName = Path.GetTempFileName();
var fileStream = File.Create(fileName);
await using (fileStream.ConfigureAwait(false))
@@ -152,7 +154,8 @@ public partial class ApiController
Logger.Warn($"Error during file download of {requestUrl}", ex);
try
{
File.Delete(fileName);
if (!fileName.IsNullOrEmpty())
File.Delete(fileName);
}
catch { }
throw;