|
@@ -465,9 +465,9 @@ namespace Emby.Server.Implementations.Library
|
|
|
private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers)
|
|
|
{
|
|
|
var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r))
|
|
|
- .FirstOrDefault(i => i != null);
|
|
|
+ .FirstOrDefault(i => i is not null);
|
|
|
|
|
|
- if (item != null)
|
|
|
+ if (item is not null)
|
|
|
{
|
|
|
ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this);
|
|
|
}
|
|
@@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
var fullPath = fileInfo.FullName;
|
|
|
|
|
|
- if (string.IsNullOrEmpty(collectionType) && parent != null)
|
|
|
+ if (string.IsNullOrEmpty(collectionType) && parent is not null)
|
|
|
{
|
|
|
collectionType = GetContentTypeOverride(fullPath, true);
|
|
|
}
|
|
@@ -572,7 +572,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- if (parent != null && parent.IsPhysicalRoot)
|
|
|
+ if (parent is not null && parent.IsPhysicalRoot)
|
|
|
{
|
|
|
_logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf);
|
|
|
|
|
@@ -654,7 +654,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
{
|
|
|
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
|
|
|
|
|
|
- if (parent != null)
|
|
|
+ if (parent is not null)
|
|
|
{
|
|
|
var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
|
|
|
|
|
@@ -697,7 +697,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
_logger.LogError(ex, "Error resolving path {Path}", file.FullName);
|
|
|
}
|
|
|
|
|
|
- if (result != null)
|
|
|
+ if (result is not null)
|
|
|
{
|
|
|
yield return result;
|
|
|
}
|
|
@@ -750,7 +750,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
var dbItem = GetItemById(folder.Id) as BasePluginFolder;
|
|
|
|
|
|
- if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
|
|
|
+ if (dbItem is not null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
folder = dbItem;
|
|
|
}
|
|
@@ -952,7 +952,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
.Cast<T>()
|
|
|
.FirstOrDefault();
|
|
|
|
|
|
- if (existing != null)
|
|
|
+ if (existing is not null)
|
|
|
{
|
|
|
return existing;
|
|
|
}
|
|
@@ -1181,7 +1181,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
return null;
|
|
|
}
|
|
|
})
|
|
|
- .Where(i => i != null)
|
|
|
+ .Where(i => i is not null)
|
|
|
.OrderBy(i => i)
|
|
|
.ToArray(),
|
|
|
|
|
@@ -1190,17 +1190,17 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
- if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary))
|
|
|
+ if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary))
|
|
|
{
|
|
|
info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
|
|
}
|
|
|
|
|
|
- if (libraryFolder != null)
|
|
|
+ if (libraryFolder is not null)
|
|
|
{
|
|
|
info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
|
|
info.LibraryOptions = GetLibraryOptions(libraryFolder);
|
|
|
|
|
|
- if (refreshQueue != null)
|
|
|
+ if (refreshQueue is not null)
|
|
|
{
|
|
|
info.RefreshProgress = libraryFolder.GetRefreshProgress();
|
|
|
|
|
@@ -1245,7 +1245,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
item = RetrieveItem(id);
|
|
|
|
|
|
- if (item != null)
|
|
|
+ if (item is not null)
|
|
|
{
|
|
|
RegisterItem(item);
|
|
|
}
|
|
@@ -1258,13 +1258,13 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (query.Recursive && !query.ParentId.Equals(default))
|
|
|
{
|
|
|
var parent = GetItemById(query.ParentId);
|
|
|
- if (parent != null)
|
|
|
+ if (parent is not null)
|
|
|
{
|
|
|
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User, allowExternalContent);
|
|
|
}
|
|
@@ -1282,13 +1282,13 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (query.Recursive && !query.ParentId.Equals(default))
|
|
|
{
|
|
|
var parent = GetItemById(query.ParentId);
|
|
|
- if (parent != null)
|
|
|
+ if (parent is not null)
|
|
|
{
|
|
|
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1302,7 +1302,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1313,7 +1313,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1331,7 +1331,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public List<Guid> GetItemIds(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1341,7 +1341,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1352,7 +1352,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1363,7 +1363,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1374,7 +1374,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1385,7 +1385,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1426,7 +1426,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
|
|
|
{
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1440,13 +1440,13 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (query.Recursive && !query.ParentId.Equals(default))
|
|
|
{
|
|
|
var parent = GetItemById(query.ParentId);
|
|
|
- if (parent != null)
|
|
|
+ if (parent is not null)
|
|
|
{
|
|
|
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (query.User != null)
|
|
|
+ if (query.User is not null)
|
|
|
{
|
|
|
AddUserToQuery(query, query.User);
|
|
|
}
|
|
@@ -1524,7 +1524,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (!view.DisplayParentId.Equals(default))
|
|
|
{
|
|
|
var displayParent = GetItemById(view.DisplayParentId);
|
|
|
- if (displayParent != null)
|
|
|
+ if (displayParent is not null)
|
|
|
{
|
|
|
return GetTopParentIdsForQuery(displayParent, user);
|
|
|
}
|
|
@@ -1535,7 +1535,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (!view.ParentId.Equals(default))
|
|
|
{
|
|
|
var displayParent = GetItemById(view.ParentId);
|
|
|
- if (displayParent != null)
|
|
|
+ if (displayParent is not null)
|
|
|
{
|
|
|
return GetTopParentIdsForQuery(displayParent, user);
|
|
|
}
|
|
@@ -1544,7 +1544,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
|
|
|
// Handle grouping
|
|
|
- if (user != null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
|
|
|
+ if (user is not null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
|
|
|
&& user.GetPreference(PreferenceKind.GroupedFolders).Length > 0)
|
|
|
{
|
|
|
return GetUserRootFolder()
|
|
@@ -1564,7 +1564,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
|
|
|
var topParent = item.GetTopParent();
|
|
|
- if (topParent != null)
|
|
|
+ if (topParent is not null)
|
|
|
{
|
|
|
return new[] { topParent.Id };
|
|
|
}
|
|
@@ -1589,7 +1589,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
return items
|
|
|
.SelectMany(i => i.ToArray())
|
|
|
.Select(ResolveIntro)
|
|
|
- .Where(i => i != null);
|
|
|
+ .Where(i => i is not null);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1648,7 +1648,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
// Pull the saved db item that will include metadata
|
|
|
var dbItem = GetItemById(video.Id) as Video;
|
|
|
|
|
|
- if (dbItem != null)
|
|
|
+ if (dbItem is not null)
|
|
|
{
|
|
|
video = dbItem;
|
|
|
}
|
|
@@ -1685,7 +1685,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
IOrderedEnumerable<BaseItem> orderedItems = null;
|
|
|
|
|
|
- foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c != null))
|
|
|
+ foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c is not null))
|
|
|
{
|
|
|
if (isFirst)
|
|
|
{
|
|
@@ -1781,7 +1781,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
RegisterItem(item);
|
|
|
}
|
|
|
|
|
|
- if (ItemAdded != null)
|
|
|
+ if (ItemAdded is not null)
|
|
|
{
|
|
|
foreach (var item in items)
|
|
|
{
|
|
@@ -1811,7 +1811,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
private bool ImageNeedsRefresh(ItemImageInfo image)
|
|
|
{
|
|
|
- if (image.Path != null && image.IsLocalFile)
|
|
|
+ if (image.Path is not null && image.IsLocalFile)
|
|
|
{
|
|
|
if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash))
|
|
|
{
|
|
@@ -1829,7 +1829,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return image.Path != null && !image.IsLocalFile;
|
|
|
+ return image.Path is not null && !image.IsLocalFile;
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc />
|
|
@@ -1838,7 +1838,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
ArgumentNullException.ThrowIfNull(item);
|
|
|
|
|
|
var outdated = forceUpdate
|
|
|
- ? item.ImageInfos.Where(i => i.Path != null).ToArray()
|
|
|
+ ? item.ImageInfos.Where(i => i.Path is not null).ToArray()
|
|
|
: item.ImageInfos.Where(ImageNeedsRefresh).ToArray();
|
|
|
// Skip image processing if current or live tv source
|
|
|
if (outdated.Length == 0 || item.SourceType != SourceType.Library)
|
|
@@ -1923,7 +1923,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
_itemRepository.SaveItems(items, cancellationToken);
|
|
|
|
|
|
- if (ItemUpdated != null)
|
|
|
+ if (ItemUpdated is not null)
|
|
|
{
|
|
|
foreach (var item in items)
|
|
|
{
|
|
@@ -1975,7 +1975,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
/// <param name="parent">The parent item.</param>
|
|
|
public void ReportItemRemoved(BaseItem item, BaseItem parent)
|
|
|
{
|
|
|
- if (ItemRemoved != null)
|
|
|
+ if (ItemRemoved is not null)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -2006,7 +2006,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public List<Folder> GetCollectionFolders(BaseItem item)
|
|
|
{
|
|
|
- while (item != null)
|
|
|
+ while (item is not null)
|
|
|
{
|
|
|
var parent = item.GetParent();
|
|
|
|
|
@@ -2028,7 +2028,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
|
|
|
{
|
|
|
- while (item != null)
|
|
|
+ while (item is not null)
|
|
|
{
|
|
|
var parent = item.GetParent();
|
|
|
|
|
@@ -2251,7 +2251,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (!refresh && !item.DisplayParentId.Equals(default))
|
|
|
{
|
|
|
var displayParent = GetItemById(item.DisplayParentId);
|
|
|
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
}
|
|
|
|
|
|
if (refresh)
|
|
@@ -2315,7 +2315,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (!refresh && !item.DisplayParentId.Equals(default))
|
|
|
{
|
|
|
var displayParent = GetItemById(item.DisplayParentId);
|
|
|
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
}
|
|
|
|
|
|
if (refresh)
|
|
@@ -2394,7 +2394,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (!refresh && !item.DisplayParentId.Equals(default))
|
|
|
{
|
|
|
var displayParent = GetItemById(item.DisplayParentId);
|
|
|
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
|
|
|
}
|
|
|
|
|
|
if (refresh)
|
|
@@ -2441,7 +2441,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
|
|
|
{
|
|
|
var series = episode.Series;
|
|
|
- bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
|
|
|
+ bool? isAbsoluteNaming = series is not null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
|
|
|
if (!isAbsoluteNaming.Value)
|
|
|
{
|
|
|
// In other words, no filter applied
|
|
@@ -2462,7 +2462,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
if (episodeInfo is null && parent.GetType() == typeof(Folder))
|
|
|
{
|
|
|
episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming);
|
|
|
- if (episodeInfo != null)
|
|
|
+ if (episodeInfo is not null)
|
|
|
{
|
|
|
// add the container
|
|
|
episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.');
|
|
@@ -2582,7 +2582,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
{
|
|
|
var season = episode.Season;
|
|
|
|
|
|
- if (season != null)
|
|
|
+ if (season is not null)
|
|
|
{
|
|
|
episode.ParentIndexNumber = season.IndexNumber;
|
|
|
}
|
|
@@ -2640,7 +2640,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
|
|
|
var extra = GetExtra(file, extraType.Value);
|
|
|
- if (extra != null)
|
|
|
+ if (extra is not null)
|
|
|
{
|
|
|
yield return extra;
|
|
|
}
|
|
@@ -2649,7 +2649,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType))
|
|
|
{
|
|
|
var extra = GetExtra(current, extraType.Value);
|
|
|
- if (extra != null)
|
|
|
+ if (extra is not null)
|
|
|
{
|
|
|
yield return extra;
|
|
|
}
|
|
@@ -2666,7 +2666,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
|
|
var itemById = GetItemById(extra.Id);
|
|
|
- if (itemById != null)
|
|
|
+ if (itemById is not null)
|
|
|
{
|
|
|
extra = itemById;
|
|
|
}
|
|
@@ -2681,10 +2681,10 @@ namespace Emby.Server.Implementations.Library
|
|
|
public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem)
|
|
|
{
|
|
|
string newPath;
|
|
|
- if (ownerItem != null)
|
|
|
+ if (ownerItem is not null)
|
|
|
{
|
|
|
var libraryOptions = GetLibraryOptions(ownerItem);
|
|
|
- if (libraryOptions != null)
|
|
|
+ if (libraryOptions is not null)
|
|
|
{
|
|
|
foreach (var pathInfo in libraryOptions.PathInfos)
|
|
|
{
|
|
@@ -2753,7 +2753,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
return null;
|
|
|
}
|
|
|
})
|
|
|
- .Where(i => i != null)
|
|
|
+ .Where(i => i is not null)
|
|
|
.Where(i => query.User is null ?
|
|
|
true :
|
|
|
i.IsVisible(query.User))
|
|
@@ -2838,10 +2838,10 @@ namespace Emby.Server.Implementations.Library
|
|
|
}
|
|
|
|
|
|
var mediaPathInfos = options.PathInfos;
|
|
|
- if (mediaPathInfos != null)
|
|
|
+ if (mediaPathInfos is not null)
|
|
|
{
|
|
|
var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path));
|
|
|
- if (invalidpath != null)
|
|
|
+ if (invalidpath is not null)
|
|
|
{
|
|
|
throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + ".");
|
|
|
}
|
|
@@ -2853,7 +2853,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
{
|
|
|
Directory.CreateDirectory(virtualFolderPath);
|
|
|
|
|
|
- if (collectionType != null)
|
|
|
+ if (collectionType is not null)
|
|
|
{
|
|
|
var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection");
|
|
|
|
|
@@ -2862,7 +2862,7 @@ namespace Emby.Server.Implementations.Library
|
|
|
|
|
|
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
|
|
|
|
|
|
- if (mediaPathInfos != null)
|
|
|
+ if (mediaPathInfos is not null)
|
|
|
{
|
|
|
foreach (var path in mediaPathInfos)
|
|
|
{
|