fix scheduled task crash

This commit is contained in:
Luke Pulverenti 2015-09-03 21:34:57 -04:00
parent cfd3248af7
commit 0b2c5fe6f4
3 changed files with 36 additions and 11 deletions

View File

@ -106,9 +106,16 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
public void QueueScheduledTask<T>(TaskExecutionOptions options)
where T : IScheduledTask
{
var scheduledTask = ScheduledTasks.First(t => t.ScheduledTask.GetType() == typeof(T));
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T));
QueueScheduledTask(scheduledTask, options);
if (scheduledTask == null)
{
Logger.Error("Unable to find scheduled task of type {0} in QueueScheduledTask.", typeof(T).Name);
}
else
{
QueueScheduledTask(scheduledTask, options);
}
}
public void QueueScheduledTask<T>()
@ -124,9 +131,16 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <param name="options">The task options.</param>
public void QueueScheduledTask(IScheduledTask task, TaskExecutionOptions options)
{
var scheduledTask = ScheduledTasks.First(t => t.ScheduledTask.GetType() == task.GetType());
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType());
QueueScheduledTask(scheduledTask, options);
if (scheduledTask == null)
{
Logger.Error("Unable to find scheduled task of type {0} in QueueScheduledTask.", task.GetType().Name);
}
else
{
QueueScheduledTask(scheduledTask, options);
}
}
/// <summary>

View File

@ -500,6 +500,10 @@ namespace MediaBrowser.Controller.Entities
return null;
}
set
{
}
}
public void SetParent(Folder parent)

View File

@ -618,6 +618,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
_logger.ErrorException("Error recording", ex);
recording.Status = RecordingStatus.Error;
}
finally
{
CancellationTokenSource removed;
_activeRecordings.TryRemove(timer.Id, out removed);
}
recording.DateLastUpdated = DateTime.UtcNow;
_recordingProvider.Update(recording);
@ -627,15 +632,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
OnSuccessfulRecording(recording);
_timerProvider.Delete(timer);
}
else if (DateTime.UtcNow < timer.EndDate)
{
const int retryIntervalSeconds = 60;
_logger.Info("Retrying recording in {0} seconds.", retryIntervalSeconds);
_timerProvider.StartTimer(timer, TimeSpan.FromSeconds(retryIntervalSeconds));
}
else
{
if (DateTime.UtcNow < timer.EndDate)
{
const int retryIntervalSeconds = 60;
_logger.Info("Retrying recording in {0} seconds.", retryIntervalSeconds);
_timerProvider.StartTimer(timer, TimeSpan.FromSeconds(retryIntervalSeconds));
}
_timerProvider.Delete(timer);
_recordingProvider.Delete(recording);
}
}