mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Use MinBy and MaxBy
This commit is contained in:
parent
eb59456e78
commit
e74630a613
@ -304,7 +304,7 @@ namespace Emby.Server.Implementations.Plugins
|
|||||||
// If no version is given, return the current instance.
|
// If no version is given, return the current instance.
|
||||||
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
|
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
|
||||||
|
|
||||||
plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
|
plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.MaxBy(p => p.Version);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,9 +69,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
T data,
|
T data,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var socket = GetActiveSockets()
|
var socket = GetActiveSockets().MaxBy(i => i.LastActivityDate);
|
||||||
.OrderByDescending(i => i.LastActivityDate)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (socket is null)
|
if (socket is null)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,6 @@ using MediaBrowser.Controller.Devices;
|
|||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Controller.Net;
|
|
||||||
using MediaBrowser.MediaEncoding.Encoder;
|
using MediaBrowser.MediaEncoding.Encoder;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
@ -2030,8 +2029,7 @@ public class DynamicHlsController : BaseJellyfinApiController
|
|||||||
{
|
{
|
||||||
return fileSystem.GetFiles(folder, new[] { segmentExtension }, true, false)
|
return fileSystem.GetFiles(folder, new[] { segmentExtension }, true, false)
|
||||||
.Where(i => Path.GetFileNameWithoutExtension(i.Name).StartsWith(filePrefix, StringComparison.OrdinalIgnoreCase))
|
.Where(i => Path.GetFileNameWithoutExtension(i.Name).StartsWith(filePrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
.OrderByDescending(fileSystem.GetLastWriteTimeUtc)
|
.MaxBy(fileSystem.GetLastWriteTimeUtc);
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ public class PluginsController : BaseJellyfinApiController
|
|||||||
var plugins = _pluginManager.Plugins.Where(p => p.Id.Equals(pluginId)).ToList();
|
var plugins = _pluginManager.Plugins.Where(p => p.Id.Equals(pluginId)).ToList();
|
||||||
|
|
||||||
// Select the un-instanced one first.
|
// Select the un-instanced one first.
|
||||||
var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
|
var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.MinBy(p => p.Manifest.Status);
|
||||||
|
|
||||||
if (plugin is not null)
|
if (plugin is not null)
|
||||||
{
|
{
|
||||||
|
@ -1256,8 +1256,7 @@ namespace Jellyfin.Networking.Manager
|
|||||||
// Look for the best internal address.
|
// Look for the best internal address.
|
||||||
bindAddress = addresses
|
bindAddress = addresses
|
||||||
.Where(p => IsInLocalNetwork(p) && (p.Contains(source) || p.Equals(IPAddress.None)))
|
.Where(p => IsInLocalNetwork(p) && (p.Contains(source) || p.Equals(IPAddress.None)))
|
||||||
.OrderBy(p => p.Tag)
|
.MinBy(p => p.Tag)?.Address;
|
||||||
.FirstOrDefault()?.Address;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bindAddress is not null)
|
if (bindAddress is not null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user