mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ProcessExt: WaitForExitAndWarn
This commit is contained in:
parent
a7aaac425a
commit
344c8e40d6
22
Wabbajack.Common/Extensions/ProcessExt.cs
Normal file
22
Wabbajack.Common/Extensions/ProcessExt.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public static class ProcessExt
|
||||
{
|
||||
public static void WaitForExitAndWarn(this Process process, TimeSpan warningTimeout, string processTitle)
|
||||
{
|
||||
if (!process.WaitForExit((int)warningTimeout.TotalMilliseconds))
|
||||
{
|
||||
Utils.Status($"{processTitle} - Taking a long time to exit.", alsoLog: true);
|
||||
process.WaitForExit();
|
||||
Utils.Status($"{processTitle} - Exited after a long period.", alsoLog: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -107,7 +107,7 @@ namespace Wabbajack.Common
|
||||
Utils.Error(e, "Error while reading StandardOutput for innounp.exe");
|
||||
}
|
||||
|
||||
p.WaitForExit();
|
||||
p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Extracting {name}");
|
||||
if (p.ExitCode == 0)
|
||||
return;
|
||||
|
||||
@ -204,15 +204,10 @@ namespace Wabbajack.Common
|
||||
{
|
||||
}
|
||||
|
||||
if (!p.WaitForExit(30000))
|
||||
{
|
||||
Utils.Status($"Extracting {name} - Taking a long time to exit.", alsoLog: true);
|
||||
p.WaitForExit();
|
||||
}
|
||||
p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Extracting {name}");
|
||||
|
||||
if (p.ExitCode == 0)
|
||||
{
|
||||
Utils.Log(new GenericInfo($"Extracted {Path.GetFileName(source)}"));
|
||||
return;
|
||||
}
|
||||
Utils.Log(new _7zipReturnError(p.ExitCode, source, dest, p.StandardOutput.ReadToEnd()));
|
||||
@ -260,7 +255,7 @@ namespace Wabbajack.Common
|
||||
Utils.Status($"Testing {name} - {line.Trim()}");
|
||||
}
|
||||
|
||||
p.WaitForExit();
|
||||
p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Testing {name}");
|
||||
return p.ExitCode == 0;
|
||||
}
|
||||
|
||||
@ -297,7 +292,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
} catch (Exception){}
|
||||
|
||||
testP.WaitForExit();
|
||||
testP.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Can Extract Check {v}");
|
||||
return testP.ExitCode == 0;
|
||||
}
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ namespace Wabbajack.Common
|
||||
if (line == null) break;
|
||||
Status(line);
|
||||
}
|
||||
p.WaitForExit();
|
||||
p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Deletion process of {path}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -103,6 +103,7 @@
|
||||
<Compile Include="Extensions\EnumerableExt.cs" />
|
||||
<Compile Include="Extensions\EnumExt.cs" />
|
||||
<Compile Include="Extensions\HashHelper.cs" />
|
||||
<Compile Include="Extensions\ProcessExt.cs" />
|
||||
<Compile Include="Extensions\RxExt.cs" />
|
||||
<Compile Include="Extensions\TaskExt.cs" />
|
||||
<Compile Include="FileExtractor.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user