From fb0bfe8e609f0ba7d6ca912dbbc3232a7c1a29d9 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sat, 21 Dec 2019 20:59:18 -0600 Subject: [PATCH 1/3] Added another missing PMap overload --- Wabbajack.Common/Utils.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index 7d572be6..b1c1e8fc 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Data.HashFunction.xxHash; using System.Diagnostics; @@ -541,6 +541,18 @@ namespace Wabbajack.Common }); } + public static async Task PMap(this IEnumerable coll, WorkQueue queue, StatusUpdateTracker updateTracker, + Func f) + { + var cnt = 0; + var collist = coll.ToList(); + await collist.PMap(queue, async itm => + { + updateTracker.MakeUpdate(collist.Count, Interlocked.Increment(ref cnt)); + await f(itm); + }); + } + public static async Task PMap(this IEnumerable coll, WorkQueue queue, StatusUpdateTracker updateTracker, Action f) { @@ -554,7 +566,6 @@ namespace Wabbajack.Common }); } - public static async Task PMap(this IEnumerable coll, WorkQueue queue, Func f) { @@ -592,7 +603,6 @@ namespace Wabbajack.Common return await Task.WhenAll(tasks); } - public static async Task PMap(this IEnumerable coll, WorkQueue queue, Func> f) { From a7aaac425a25a1f22bc885b575bdb262509b70e6 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sun, 22 Dec 2019 00:27:57 -0600 Subject: [PATCH 2/3] Added extra logging to 7z extraction completion --- Wabbajack.Common/FileExtractor.cs | 8 +++++++- Wabbajack.Common/Utils.cs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Wabbajack.Common/FileExtractor.cs b/Wabbajack.Common/FileExtractor.cs index 2b7ecbcd..904111a4 100644 --- a/Wabbajack.Common/FileExtractor.cs +++ b/Wabbajack.Common/FileExtractor.cs @@ -204,9 +204,15 @@ namespace Wabbajack.Common { } - p.WaitForExit(); + if (!p.WaitForExit(30000)) + { + Utils.Status($"Extracting {name} - Taking a long time to exit.", alsoLog: true); + p.WaitForExit(); + } + if (p.ExitCode == 0) { + Utils.Log(new GenericInfo($"Extracted {Path.GetFileName(source)}")); return; } Utils.Log(new _7zipReturnError(p.ExitCode, source, dest, p.StandardOutput.ReadToEnd())); diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index b1c1e8fc..c72edef5 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -121,9 +121,13 @@ namespace Wabbajack.Common } } - public static void Status(string msg, int progress = 0) + public static void Status(string msg, int progress = 0, bool alsoLog = false) { WorkQueue.AsyncLocalCurrentQueue.Value?.Report(msg, progress); + if (alsoLog) + { + Utils.Log(msg); + } } /// From 344c8e40d6e1b3beae8d7a945f407839158b9440 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Sun, 22 Dec 2019 00:50:11 -0600 Subject: [PATCH 3/3] ProcessExt: WaitForExitAndWarn --- Wabbajack.Common/Extensions/ProcessExt.cs | 22 ++++++++++++++++++++++ Wabbajack.Common/FileExtractor.cs | 13 ++++--------- Wabbajack.Common/Utils.cs | 2 +- Wabbajack.Common/Wabbajack.Common.csproj | 1 + 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 Wabbajack.Common/Extensions/ProcessExt.cs diff --git a/Wabbajack.Common/Extensions/ProcessExt.cs b/Wabbajack.Common/Extensions/ProcessExt.cs new file mode 100644 index 00000000..04277531 --- /dev/null +++ b/Wabbajack.Common/Extensions/ProcessExt.cs @@ -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); + } + } + } +} diff --git a/Wabbajack.Common/FileExtractor.cs b/Wabbajack.Common/FileExtractor.cs index 904111a4..6a9faaf7 100644 --- a/Wabbajack.Common/FileExtractor.cs +++ b/Wabbajack.Common/FileExtractor.cs @@ -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; } } diff --git a/Wabbajack.Common/Utils.cs b/Wabbajack.Common/Utils.cs index c72edef5..fb02fede 100644 --- a/Wabbajack.Common/Utils.cs +++ b/Wabbajack.Common/Utils.cs @@ -1008,7 +1008,7 @@ namespace Wabbajack.Common if (line == null) break; Status(line); } - p.WaitForExit(); + p.WaitForExitAndWarn(TimeSpan.FromSeconds(30), $"Deletion process of {path}"); } /// diff --git a/Wabbajack.Common/Wabbajack.Common.csproj b/Wabbajack.Common/Wabbajack.Common.csproj index b8cfa161..bbe54f78 100644 --- a/Wabbajack.Common/Wabbajack.Common.csproj +++ b/Wabbajack.Common/Wabbajack.Common.csproj @@ -103,6 +103,7 @@ +