From 7ea5608683500615815e8b4de8f5f82f426f3dc5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 12 Jul 2016 13:16:34 -0400 Subject: [PATCH] add safeguard on interval trigger duration --- MediaBrowser.Common/ScheduledTasks/IntervalTrigger.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Common/ScheduledTasks/IntervalTrigger.cs b/MediaBrowser.Common/ScheduledTasks/IntervalTrigger.cs index 5107db6c4d..8038d5551d 100644 --- a/MediaBrowser.Common/ScheduledTasks/IntervalTrigger.cs +++ b/MediaBrowser.Common/ScheduledTasks/IntervalTrigger.cs @@ -60,7 +60,15 @@ namespace MediaBrowser.Common.ScheduledTasks triggerDate = DateTime.UtcNow.AddMinutes(1); } - Timer = new Timer(state => OnTriggered(), null, triggerDate - DateTime.UtcNow, TimeSpan.FromMilliseconds(-1)); + var dueTime = triggerDate - DateTime.UtcNow; + var maxDueTime = TimeSpan.FromDays(7); + + if (dueTime > maxDueTime) + { + dueTime = maxDueTime; + } + + Timer = new Timer(state => OnTriggered(), null, dueTime, TimeSpan.FromMilliseconds(-1)); } ///