From 9497b5fa30e71abbd4f1e13e7d2d7be9d726423f Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Tue, 9 Jan 2018 13:23:28 +0100
Subject: [PATCH] Remove the CheckGraceLocation() wrapper.

Make GraceLocationSummary() return an empty string instead, if no
expired folders exist in the grace location.

Refers to #1
---
 AutoTx/AutoTx.cs | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs
index 3c65634..4608042 100644
--- a/AutoTx/AutoTx.cs
+++ b/AutoTx/AutoTx.cs
@@ -213,12 +213,17 @@ namespace AutoTx
             }
 
 
-            msg += "\n------ Grace location status ------\n";
+            msg += "\n------ Grace location status (threshold: " + _config.GracePeriod + ") ------\n";
             try {
-                msg += GraceLocationSummary(_config.GracePeriod);
+                var tmp = GraceLocationSummary(_config.GracePeriod);
+                if (string.IsNullOrEmpty(tmp)) {
+                    msg += " -- NO EXPIRED folders in grace location! --\n";
+                } else {
+                    msg += tmp;
+                }
             }
             catch (Exception ex) {
-                writeLog("CheckGraceLocation() failed: " + ex.Message, true);
+                writeLog("GraceLocationSummary() failed: " + ex.Message, true);
             }
 
             if (!string.IsNullOrEmpty(_config.ValidationWarnings)) {
@@ -766,7 +771,7 @@ namespace AutoTx
                         sourceDirectory.Parent.Delete();
                     // check age and size of existing folders in the grace location after
                     // a transfer has completed, trigger a notification if necessary:
-                    CheckGraceLocation();
+                    writeLogDebug(GraceLocationSummary(_config.GracePeriod));
                     return;
                 }
                 errMsg = "unable to move " + sourceDirectory.FullName;
@@ -923,10 +928,6 @@ namespace AutoTx
                 .Sum(file => file.Length);
         }
 
-        public void CheckGraceLocation() {
-            writeLogDebug(GraceLocationSummary(_config.GracePeriod));
-        }
-
         /// <summary>
         /// Generate a report on expired folders in the grace location.
         /// 
@@ -946,8 +947,9 @@ namespace AutoTx
                 }
             }
             if (string.IsNullOrEmpty(report))
-                report = " -- NONE --\n";
-            return  "Folders older than " + threshold + " days in grace location:\n" + report;
+                return "";
+            report = "Expired folders in grace location:\n" + report;
+            return report;
         }
 
         /// <summary>
-- 
GitLab