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

Fix calculations of time span values.

parent 3d8e7875
No related branches found
No related tags found
No related merge requests found
......@@ -399,8 +399,8 @@ namespace AutoTx
CheckFreeDiskSpace();
UpdateServiceState();
var delta = DateTime.Now - _lastUserDirCheck;
if (delta.Seconds >= 120)
var delta = (int)(DateTime.Now - _lastUserDirCheck).TotalSeconds;
if (delta >= 120)
CreateIncomingDirectories();
// tasks depending on the service state:
......@@ -970,7 +970,7 @@ namespace AutoTx
private Dictionary<string, List<Tuple<DirectoryInfo, long, int>>> ExpiredDirs(int thresh) {
var collection = new Dictionary<string, List<Tuple<DirectoryInfo, long, int>>>();
var graceDir = new DirectoryInfo(Path.Combine(_managedPath, "DONE"));
var now = DateTime.UtcNow;
var now = DateTime.Now;
foreach (var userdir in graceDir.GetDirectories()) {
var expired = new List<Tuple<DirectoryInfo, long, int>>();
foreach (var subdir in userdir.GetDirectories()) {
......
......@@ -80,9 +80,12 @@ namespace AutoTx
if (_config.SendAdminNotification == false)
return;
var delta = DateTime.Now - _status.LastAdminNotification;
if (delta.Minutes < _config.AdminNotificationDelta)
var delta = (int)(DateTime.Now - _status.LastAdminNotification).TotalMinutes;
if (delta < _config.AdminNotificationDelta) {
writeLogDebug("Suppressed admin email, interval too short (" + delta + " vs. " +
_config.AdminNotificationDelta + "):\n\n" + subject + "\n" + body);
return;
}
if (subject == "") {
subject = ServiceName +
......@@ -103,8 +106,8 @@ namespace AutoTx
/// </summary>
/// <param name="spaceDetails">String describing the drives being low on space.</param>
public void SendLowSpaceMail(string spaceDetails) {
var delta = DateTime.Now - _status.LastStorageNotification;
if (delta.Minutes < _config.StorageNotificationDelta)
var delta = (int)(DateTime.Now - _status.LastStorageNotification).TotalMinutes;
if (delta < _config.StorageNotificationDelta)
return;
writeLog("WARNING: " + spaceDetails);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment