From c94b115c2fd759019e251e3eeeff85d5c152c508 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 16 Jan 2018 19:47:59 +0000 Subject: [PATCH] Print fewer download updates in headless mode --- Cmdline/ConsoleUser.cs | 11 +++++++++-- Netkan/ConsoleUser.cs | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cmdline/ConsoleUser.cs b/Cmdline/ConsoleUser.cs index bceb89ad3f..12a733fcf0 100644 --- a/Cmdline/ConsoleUser.cs +++ b/Cmdline/ConsoleUser.cs @@ -231,9 +231,15 @@ protected override void ReportProgress(string format, int percent) { if (Regex.IsMatch(format, "download", RegexOptions.IgnoreCase)) { - Console.Write( + // In headless mode, only print a new message if the percent has changed, + // to reduce clutter in Jenkins for large downloads + if (!m_Headless || percent != previousPercent) + { // The \r at the front here causes download messages to *overwrite* each other. - "\r{0} - {1}% ", format, percent); + Console.Write( + "\r{0} - {1}% ", format, percent); + previousPercent = percent; + } } else { @@ -244,5 +250,6 @@ protected override void ReportProgress(string format, int percent) } } + private int previousPercent = -1; } } diff --git a/Netkan/ConsoleUser.cs b/Netkan/ConsoleUser.cs index 4be2a6c928..6f46ccc03d 100644 --- a/Netkan/ConsoleUser.cs +++ b/Netkan/ConsoleUser.cs @@ -60,9 +60,15 @@ protected override void ReportProgress(string format, int percent) { if (Regex.IsMatch(format, "download", RegexOptions.IgnoreCase)) { - Console.Write( + // In headless mode, only print a new message if the percent has changed, + // to reduce clutter in Jenkins for large downloads + if (!m_Headless || percent != previousPercent) + { // The \r at the front here causes download messages to *overwrite* each other. - "\r{0} - {1}% ", format, percent); + Console.Write( + "\r{0} - {1}% ", format, percent); + previousPercent = percent; + } } else { @@ -73,5 +79,6 @@ protected override void ReportProgress(string format, int percent) } } + private int previousPercent = -1; } }