From 9c75a68b888d39256b1cb2b403eab6a4f92c684a Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Wed, 20 Dec 2017 16:37:07 +0100
Subject: [PATCH] Turn CheckGraceLocation() into a wrapper for
 GraceLocationSummary().

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

diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs
index 20175a5..1bf7190 100644
--- a/AutoTx/AutoTx.cs
+++ b/AutoTx/AutoTx.cs
@@ -922,6 +922,10 @@ namespace AutoTx
                 .Sum(file => file.Length);
         }
 
+        public void CheckGraceLocation() {
+            writeLogDebug(GraceLocationSummary());
+        }
+
         /// <summary>
         /// Generate a report on expired folders in the grace location.
         /// 
@@ -929,7 +933,7 @@ namespace AutoTx
         /// name-timestamp exceeds the configured grace period and generate a summary
         /// containing the age and size of those directories.
         /// </summary>
-        public void CheckGraceLocation() {
+        public string GraceLocationSummary() {
             var expired = ExpiredDirs(_config.GracePeriod);
             var report = "";
             foreach (var userdir in expired.Keys) {
@@ -939,7 +943,9 @@ namespace AutoTx
                         subdir.Item1, subdir.Item2, subdir.Item3);
                 }
             }
-            writeLogDebug("Expired folders in grace location:\n" + report);
+            if (string.IsNullOrEmpty(report))
+                return "No expired folders in grace location.\n";
+            return  "Expired folders in grace location:\n" + report;
         }
 
         /// <summary>
-- 
GitLab