mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-27 02:56:54 +01:00
Use helper function to compare guid (#10825)
This commit is contained in:
@@ -732,7 +732,7 @@ namespace Emby.Server.Implementations.Library
|
||||
Path = path
|
||||
};
|
||||
|
||||
if (folder.Id.Equals(default))
|
||||
if (folder.Id.IsEmpty())
|
||||
{
|
||||
if (string.IsNullOrEmpty(folder.Path))
|
||||
{
|
||||
@@ -1219,7 +1219,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <c>null</c>.</exception>
|
||||
public BaseItem GetItemById(Guid id)
|
||||
{
|
||||
if (id.Equals(default))
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentException("Guid can't be empty", nameof(id));
|
||||
}
|
||||
@@ -1241,7 +1241,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public List<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent)
|
||||
{
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
if (query.Recursive && !query.ParentId.IsEmpty())
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent is not null)
|
||||
@@ -1272,7 +1272,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public int GetCount(InternalItemsQuery query)
|
||||
{
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
if (query.Recursive && !query.ParentId.IsEmpty())
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent is not null)
|
||||
@@ -1430,7 +1430,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
|
||||
{
|
||||
if (query.Recursive && !query.ParentId.Equals(default))
|
||||
if (query.Recursive && !query.ParentId.IsEmpty())
|
||||
{
|
||||
var parent = GetItemById(query.ParentId);
|
||||
if (parent is not null)
|
||||
@@ -1486,7 +1486,7 @@ namespace Emby.Server.Implementations.Library
|
||||
private void AddUserToQuery(InternalItemsQuery query, User user, bool allowExternalContent = true)
|
||||
{
|
||||
if (query.AncestorIds.Length == 0 &&
|
||||
query.ParentId.Equals(default) &&
|
||||
query.ParentId.IsEmpty() &&
|
||||
query.ChannelIds.Count == 0 &&
|
||||
query.TopParentIds.Length == 0 &&
|
||||
string.IsNullOrEmpty(query.AncestorWithPresentationUniqueKey) &&
|
||||
@@ -1520,7 +1520,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// Translate view into folders
|
||||
if (!view.DisplayParentId.Equals(default))
|
||||
if (!view.DisplayParentId.IsEmpty())
|
||||
{
|
||||
var displayParent = GetItemById(view.DisplayParentId);
|
||||
if (displayParent is not null)
|
||||
@@ -1531,7 +1531,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return Array.Empty<Guid>();
|
||||
}
|
||||
|
||||
if (!view.ParentId.Equals(default))
|
||||
if (!view.ParentId.IsEmpty())
|
||||
{
|
||||
var displayParent = GetItemById(view.ParentId);
|
||||
if (displayParent is not null)
|
||||
@@ -2137,7 +2137,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
while (!item.ParentId.Equals(default))
|
||||
while (!item.ParentId.IsEmpty())
|
||||
{
|
||||
var parent = item.GetParent();
|
||||
if (parent is null || parent is AggregateFolder)
|
||||
@@ -2215,7 +2215,7 @@ namespace Emby.Server.Implementations.Library
|
||||
CollectionType? viewType,
|
||||
string sortName)
|
||||
{
|
||||
var parentIdString = parentId.Equals(default)
|
||||
var parentIdString = parentId.IsEmpty()
|
||||
? null
|
||||
: parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var idValues = "38_namedview_" + name + user.Id.ToString("N", CultureInfo.InvariantCulture) + (parentIdString ?? string.Empty) + (viewType?.ToString() ?? string.Empty);
|
||||
@@ -2251,7 +2251,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
if (!refresh && !item.DisplayParentId.IsEmpty())
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
@@ -2315,7 +2315,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
if (!refresh && !item.DisplayParentId.IsEmpty())
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
@@ -2345,7 +2345,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(name);
|
||||
|
||||
var parentIdString = parentId.Equals(default)
|
||||
var parentIdString = parentId.IsEmpty()
|
||||
? null
|
||||
: parentId.ToString("N", CultureInfo.InvariantCulture);
|
||||
var idValues = "37_namedview_" + name + (parentIdString ?? string.Empty) + (viewType?.ToString() ?? string.Empty);
|
||||
@@ -2391,7 +2391,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var refresh = isNew || DateTime.UtcNow - item.DateLastRefreshed >= _viewRefreshInterval;
|
||||
|
||||
if (!refresh && !item.DisplayParentId.Equals(default))
|
||||
if (!refresh && !item.DisplayParentId.IsEmpty())
|
||||
{
|
||||
var displayParent = GetItemById(item.DisplayParentId);
|
||||
refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
||||
@@ -2419,7 +2419,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return GetItemById(parentId.Value);
|
||||
}
|
||||
|
||||
if (userId.HasValue && !userId.Equals(default))
|
||||
if (!userId.IsNullOrEmpty())
|
||||
{
|
||||
return GetUserRootFolder();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
@@ -524,10 +525,10 @@ namespace Emby.Server.Implementations.Library
|
||||
_logger.LogInformation("Live stream opened: {@MediaSource}", mediaSource);
|
||||
var clone = JsonSerializer.Deserialize<MediaSourceInfo>(json, _jsonOptions);
|
||||
|
||||
if (!request.UserId.Equals(default))
|
||||
if (!request.UserId.IsEmpty())
|
||||
{
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
var item = request.ItemId.Equals(default)
|
||||
var item = request.ItemId.IsEmpty()
|
||||
? null
|
||||
: _libraryManager.GetItemById(request.ItemId);
|
||||
SetDefaultAudioAndSubtitleStreamIndexes(item, clone, user);
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -80,7 +81,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
return Guid.Empty;
|
||||
}
|
||||
}).Where(i => !i.Equals(default)).ToArray();
|
||||
}).Where(i => !i.IsEmpty()).ToArray();
|
||||
|
||||
return GetInstantMixFromGenreIds(genreIds, user, dtoOptions);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Library
|
||||
public QueryResult<SearchHintInfo> GetSearchHints(SearchQuery query)
|
||||
{
|
||||
User user = null;
|
||||
if (!query.UserId.Equals(default))
|
||||
if (!query.UserId.IsEmpty())
|
||||
{
|
||||
user = _userManager.GetUserById(query.UserId);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (searchQuery.IncludeItemTypes.Length == 1 && searchQuery.IncludeItemTypes[0] == BaseItemKind.MusicArtist)
|
||||
{
|
||||
if (!searchQuery.ParentId.Equals(default))
|
||||
if (!searchQuery.ParentId.IsEmpty())
|
||||
{
|
||||
searchQuery.AncestorIds = new[] { searchQuery.ParentId };
|
||||
searchQuery.ParentId = Guid.Empty;
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
@@ -151,7 +152,7 @@ namespace Emby.Server.Implementations.Library
|
||||
var index = Array.IndexOf(orders, i.Id);
|
||||
if (index == -1
|
||||
&& i is UserView view
|
||||
&& !view.DisplayParentId.Equals(default))
|
||||
&& !view.DisplayParentId.IsEmpty())
|
||||
{
|
||||
index = Array.IndexOf(orders, view.DisplayParentId);
|
||||
}
|
||||
@@ -253,7 +254,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var parents = new List<BaseItem>();
|
||||
|
||||
if (!parentId.Equals(default))
|
||||
if (!parentId.IsEmpty())
|
||||
{
|
||||
var parentItem = _libraryManager.GetItemById(parentId);
|
||||
if (parentItem is Channel)
|
||||
|
||||
Reference in New Issue
Block a user