mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
Use helper function to compare guid (#10825)
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -184,7 +185,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <exception cref="ArgumentNullException">The id is empty.</exception>
|
||||
public BaseItem FindVirtualChild(Guid id)
|
||||
{
|
||||
if (id.Equals(default))
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess, IHasLookupInfo<ArtistInfo>
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool IsAccessedByName => ParentId.Equals(default);
|
||||
public bool IsAccessedByName => ParentId.IsEmpty();
|
||||
|
||||
[JsonIgnore]
|
||||
public override bool IsFolder => !IsAccessedByName;
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ChannelId.Equals(default))
|
||||
if (!ChannelId.IsEmpty())
|
||||
{
|
||||
return SourceType.Channel;
|
||||
}
|
||||
@@ -530,7 +530,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
get
|
||||
{
|
||||
var id = DisplayParentId;
|
||||
if (id.Equals(default))
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -746,7 +746,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
public virtual bool StopRefreshIfLocalMetadataFound => true;
|
||||
|
||||
[JsonIgnore]
|
||||
protected virtual bool SupportsOwnedItems => !ParentId.Equals(default) && IsFileProtocol;
|
||||
protected virtual bool SupportsOwnedItems => !ParentId.IsEmpty() && IsFileProtocol;
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual bool SupportsPeople => false;
|
||||
@@ -823,7 +823,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
public BaseItem GetOwner()
|
||||
{
|
||||
var ownerId = OwnerId;
|
||||
return ownerId.Equals(default) ? null : LibraryManager.GetItemById(ownerId);
|
||||
return ownerId.IsEmpty() ? null : LibraryManager.GetItemById(ownerId);
|
||||
}
|
||||
|
||||
public bool CanDelete(User user, List<Folder> allCollectionFolders)
|
||||
@@ -968,7 +968,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
public BaseItem GetParent()
|
||||
{
|
||||
var parentId = ParentId;
|
||||
if (parentId.Equals(default))
|
||||
if (parentId.IsEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -1361,7 +1361,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var tasks = extras.Select(i =>
|
||||
{
|
||||
var subOptions = new MetadataRefreshOptions(options);
|
||||
if (!i.OwnerId.Equals(ownerId) || !i.ParentId.Equals(default))
|
||||
if (!i.OwnerId.Equals(ownerId) || !i.ParentId.IsEmpty())
|
||||
{
|
||||
i.OwnerId = ownerId;
|
||||
i.ParentId = Guid.Empty;
|
||||
@@ -1673,7 +1673,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
// First get using the cached Id
|
||||
if (info.ItemId.HasValue)
|
||||
{
|
||||
if (info.ItemId.Value.Equals(default))
|
||||
if (info.ItemId.Value.IsEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -2439,7 +2439,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
if (video.OwnerId.Equals(default))
|
||||
if (video.OwnerId.IsEmpty())
|
||||
{
|
||||
video.OwnerId = this.Id;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Collections;
|
||||
@@ -198,7 +199,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
item.SetParent(this);
|
||||
|
||||
if (item.Id.Equals(default))
|
||||
if (item.Id.IsEmpty())
|
||||
{
|
||||
item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType());
|
||||
}
|
||||
@@ -697,7 +698,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (this is not UserRootFolder
|
||||
&& this is not AggregateFolder
|
||||
&& query.ParentId.Equals(default))
|
||||
&& query.ParentId.IsEmpty())
|
||||
{
|
||||
query.Parent = this;
|
||||
}
|
||||
@@ -840,7 +841,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
if (query.AdjacentTo.HasValue && !query.AdjacentTo.Value.Equals(default))
|
||||
if (!query.AdjacentTo.IsNullOrEmpty())
|
||||
{
|
||||
Logger.LogDebug("Query requires post-filtering due to AdjacentTo");
|
||||
return true;
|
||||
@@ -987,7 +988,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
#pragma warning restore CA1309
|
||||
|
||||
// This must be the last filter
|
||||
if (query.AdjacentTo.HasValue && !query.AdjacentTo.Value.Equals(default))
|
||||
if (!query.AdjacentTo.IsNullOrEmpty())
|
||||
{
|
||||
items = UserViewBuilder.FilterForAdjacency(items.ToList(), query.AdjacentTo.Value);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
@@ -74,12 +75,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
get
|
||||
{
|
||||
var seriesId = SeriesId;
|
||||
if (seriesId.Equals(default))
|
||||
if (seriesId.IsEmpty())
|
||||
{
|
||||
seriesId = FindSeriesId();
|
||||
}
|
||||
|
||||
return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series);
|
||||
return seriesId.IsEmpty() ? null : (LibraryManager.GetItemById(seriesId) as Series);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +90,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
get
|
||||
{
|
||||
var seasonId = SeasonId;
|
||||
if (seasonId.Equals(default))
|
||||
if (seasonId.IsEmpty())
|
||||
{
|
||||
seasonId = FindSeasonId();
|
||||
}
|
||||
|
||||
return seasonId.Equals(default) ? null : (LibraryManager.GetItemById(seasonId) as Season);
|
||||
return seasonId.IsEmpty() ? null : (LibraryManager.GetItemById(seasonId) as Season);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
|
||||
var seasonId = SeasonId;
|
||||
|
||||
if (!seasonId.Equals(default) && !list.Contains(seasonId))
|
||||
if (!seasonId.IsEmpty() && !list.Contains(seasonId))
|
||||
{
|
||||
list.Add(seasonId);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Querying;
|
||||
@@ -48,12 +49,12 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
get
|
||||
{
|
||||
var seriesId = SeriesId;
|
||||
if (seriesId.Equals(default))
|
||||
if (seriesId.IsEmpty())
|
||||
{
|
||||
seriesId = FindSeriesId();
|
||||
}
|
||||
|
||||
return seriesId.Equals(default) ? null : (LibraryManager.GetItemById(seriesId) as Series);
|
||||
return seriesId.IsEmpty() ? null : (LibraryManager.GetItemById(seriesId) as Series);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
||||
{
|
||||
if (!DisplayParentId.Equals(default))
|
||||
if (!DisplayParentId.IsEmpty())
|
||||
{
|
||||
yield return DisplayParentId;
|
||||
}
|
||||
else if (!ParentId.Equals(default))
|
||||
else if (!ParentId.IsEmpty())
|
||||
{
|
||||
yield return ParentId;
|
||||
}
|
||||
@@ -95,11 +95,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
var parent = this as Folder;
|
||||
|
||||
if (!DisplayParentId.Equals(default))
|
||||
if (!DisplayParentId.IsEmpty())
|
||||
{
|
||||
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
|
||||
}
|
||||
else if (!ParentId.Equals(default))
|
||||
else if (!ParentId.IsEmpty())
|
||||
{
|
||||
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var user = query.User;
|
||||
|
||||
// This must be the last filter
|
||||
if (query.AdjacentTo.HasValue && !query.AdjacentTo.Value.Equals(default))
|
||||
if (!query.AdjacentTo.IsNullOrEmpty())
|
||||
{
|
||||
items = FilterForAdjacency(items.ToList(), query.AdjacentTo.Value);
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
foreach (var child in LinkedAlternateVersions)
|
||||
{
|
||||
// Reset the cached value
|
||||
if (child.ItemId.HasValue && child.ItemId.Value.Equals(default))
|
||||
if (child.ItemId.IsNullOrEmpty())
|
||||
{
|
||||
child.ItemId = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user