add try catch and directory check to stream method

This commit is contained in:
IsWaffle 2023-03-05 09:23:03 -05:00
parent 7f8268200a
commit e7a38ac30d

View File

@ -43,6 +43,11 @@ namespace SPT_AKI_Installer.Aki.Helper
private static async Task<GenericResult> ProcessInboundStreamAsync(FileInfo cacheFile, Stream downloadStream, string expectedHash = null) private static async Task<GenericResult> ProcessInboundStreamAsync(FileInfo cacheFile, Stream downloadStream, string expectedHash = null)
{ {
try
{
cacheFile.Refresh();
Directory.CreateDirectory(_cachePath);
if (cacheFile.Exists) if (cacheFile.Exists)
{ {
if (expectedHash != null && FileHashHelper.CheckHash(cacheFile, expectedHash)) if (expectedHash != null && FileHashHelper.CheckHash(cacheFile, expectedHash))
@ -68,6 +73,11 @@ namespace SPT_AKI_Installer.Aki.Helper
return GenericResult.FromSuccess(); return GenericResult.FromSuccess();
} }
catch(Exception ex)
{
return GenericResult.FromError(ex.Message);
}
}
private static async Task<GenericResult> ProcessInboundFileAsync(FileInfo cacheFile, string targetLink, IProgress<double> progress, string expectedHash = null) private static async Task<GenericResult> ProcessInboundFileAsync(FileInfo cacheFile, string targetLink, IProgress<double> progress, string expectedHash = null)
{ {