Refactor TryReleaseTcpPort Process.MainModule.FileName null handling

This commit is contained in:
ChsBuffer
2021-04-30 17:01:11 +08:00
parent ccd46144ab
commit 460d295a66

View File

@@ -187,16 +187,9 @@ namespace Netch.Controllers
{
foreach (var p in PortHelper.GetProcessByUsedTcpPort(port))
{
string fileName;
try
{
fileName = p.MainModule?.FileName ?? throw new Exception(); // TODO what's this exception?
}
catch (Exception e)
{
Global.Logger.Warning(e.ToString());
var fileName = p.MainModule?.FileName;
if (fileName == null)
continue;
}
if (fileName.StartsWith(Global.NetchDir))
{