Skip to content
Snippets Groups Projects
Commit 25a3f9a7 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Convert SendGraceLocationSummary() from string to bool, w/o parameters

Having the threshold as a parameter is not necessary as the new
StorageStatus object has this property built-in already. Returning the
generated message is also not required any more as it can easily be
retrieved from that instance as well.

Relates to #20
parent c2929880
No related branches found
No related tags found
No related merge requests found
...@@ -915,9 +915,8 @@ namespace ATxService ...@@ -915,9 +915,8 @@ namespace ATxService
sourceDirectory.Delete(); sourceDirectory.Delete();
if (sourceDirectory.Parent != null) if (sourceDirectory.Parent != null)
sourceDirectory.Parent.Delete(); sourceDirectory.Parent.Delete();
// check age and size of existing folders in the grace location after // check grace location and trigger a notification if necessary:
// a transfer has completed, trigger a notification if necessary: SendGraceLocationSummary();
Log.Debug(SendGraceLocationSummary(_config.GracePeriod));
return; return;
} }
errMsg = "unable to move " + sourceDirectory.FullName; errMsg = "unable to move " + sourceDirectory.FullName;
......
...@@ -212,23 +212,26 @@ namespace ATxService ...@@ -212,23 +212,26 @@ namespace ATxService
/// GraceNotificationDelta has passed since the last email. The report will also contain a /// GraceNotificationDelta has passed since the last email. The report will also contain a
/// summary of free disk space for all configured drives. /// summary of free disk space for all configured drives.
/// </summary> /// </summary>
/// <param name="threshold">The number of days used as expiration threshold.</param> /// <returns>True if a report was sent, false otherwise (includes situations where there
/// <returns>The summary report, empty if no expired folders exist.</returns> /// are expired directories but the report has not been sent via email as the grace
private string SendGraceLocationSummary(int threshold) { /// notification delta hasn't expired yet, the report will still be logged then).</returns>
var report = FsUtils.GraceLocationSummary( private bool SendGraceLocationSummary() {
new DirectoryInfo(_config.DonePath), threshold); if (_storage.ExpiredDirsCount == 0)
if (string.IsNullOrEmpty(report)) return false;
return "";
var report = _storage.Summary() +
report += $"\n{SystemChecks.CheckFreeDiskSpace(_config.SpaceMonitoring)}" + "\nTime since last grace notification: " +
"\nTime since last grace notification: " + $"{TimeUtils.HumanSince(_status.LastGraceNotification)}\n";
$"{TimeUtils.HumanSince(_status.LastGraceNotification)}\n";
if (TimeUtils.MinutesSince(_status.LastGraceNotification) < _config.GraceNotificationDelta) if (TimeUtils.MinutesSince(_status.LastGraceNotification) < _config.GraceNotificationDelta) {
return report; Log.Debug(report);
return false;
}
_status.LastGraceNotification = DateTime.Now; _status.LastGraceNotification = DateTime.Now;
SendAdminEmail(report, "grace location summary"); SendAdminEmail(report, "grace location summary");
return report + "\nNotification sent to AdminEmailAdress.\n"; Log.Debug("Notification sent to AdminEmailAdress.");
return true;
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment