optimize checkForInactiveStreams logic
This commit is contained in:
parent
994619afb2
commit
e8a05ad996
|
@ -625,15 +625,10 @@ namespace Emby.Server.Implementations.Session
|
||||||
|
|
||||||
private async void CheckForInactiveSteams(object state)
|
private async void CheckForInactiveSteams(object state)
|
||||||
{
|
{
|
||||||
var pausedSessions = Sessions.Where(i =>
|
var inactiveSessions = Sessions.Where(i =>
|
||||||
i.NowPlayingItem is not null
|
i.NowPlayingItem is not null
|
||||||
&& i.PlayState.IsPaused
|
&& i.PlayState.IsPaused
|
||||||
&& i.LastPausedDate is not null)
|
&& (DateTime.UtcNow - i.LastPausedDate).Value.TotalMinutes > _config.Configuration.InactiveSessionThreshold);
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (pausedSessions.Count > 0)
|
|
||||||
{
|
|
||||||
var inactiveSessions = pausedSessions.Where(i => (DateTime.UtcNow - i.LastPausedDate).Value.TotalMinutes > _config.Configuration.InactiveSessionThreshold).ToList();
|
|
||||||
|
|
||||||
foreach (var session in inactiveSessions)
|
foreach (var session in inactiveSessions)
|
||||||
{
|
{
|
||||||
|
@ -657,11 +652,10 @@ namespace Emby.Server.Implementations.Session
|
||||||
_logger.LogDebug(ex, "Error calling SendPlaystateCommand for stopping inactive session {Session}.", session.Id);
|
_logger.LogDebug(ex, "Error calling SendPlaystateCommand for stopping inactive session {Session}.", session.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var playingSessions = Sessions.Where(i => i.NowPlayingItem is not null)
|
bool playingSessions = Sessions.Any(i => i.NowPlayingItem is not null);
|
||||||
.ToList();
|
|
||||||
if (playingSessions.Count == 0)
|
if (!playingSessions)
|
||||||
{
|
{
|
||||||
StopInactiveCheckTimer();
|
StopInactiveCheckTimer();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user