Added a try/catch block when unzipping files to ensure errors are properly logged, and temp files are cleaned up (#165)

This commit is contained in:
Michael Green
2023-10-17 11:22:45 +11:00
committed by GitHub
parent ffc8be3c12
commit 8688e1d5c0

View File

@@ -154,6 +154,8 @@ namespace gaseous_server.Classes
// extract the zip file and search the contents
string ExtractPath = Path.Combine(Config.LibraryConfiguration.LibraryTempDirectory, Path.GetRandomFileName());
if (!Directory.Exists(ExtractPath)) { Directory.CreateDirectory(ExtractPath); }
try
{
ZipFile.ExtractToDirectory(GameFileImportPath, ExtractPath);
// loop through contents until we find the first signature match
@@ -183,6 +185,11 @@ namespace gaseous_server.Classes
break;
}
}
}
catch (Exception ex)
{
Logging.Log(Logging.LogType.Critical, "Get Signature", "Error processing zip file: " + GameFileImportPath, ex);
}
if (Directory.Exists(ExtractPath)) { Directory.Delete(ExtractPath, true); }
}