mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
don't auto-restart during recordings
This commit is contained in:
@@ -8,6 +8,8 @@ using MediaBrowser.Model.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
{
|
||||
@@ -18,16 +20,18 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
private readonly ITaskManager _iTaskManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
|
||||
private Timer _timer;
|
||||
|
||||
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config)
|
||||
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager)
|
||||
{
|
||||
_appHost = appHost;
|
||||
_logger = logger;
|
||||
_iTaskManager = iTaskManager;
|
||||
_sessionManager = sessionManager;
|
||||
_config = config;
|
||||
_liveTvManager = liveTvManager;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
@@ -44,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
|
||||
if (_appHost.HasPendingRestart)
|
||||
{
|
||||
_timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
|
||||
_timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +76,22 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_liveTvManager.Services.Count == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
var timers = _liveTvManager.GetTimers(new TimerQuery(), CancellationToken.None).Result;
|
||||
if (timers.Items.Any(i => i.Status == RecordingStatus.InProgress))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting timers", ex);
|
||||
}
|
||||
}
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
return !_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 30);
|
||||
|
||||
Reference in New Issue
Block a user