Remove dependency on OptimizedPriorityQueue
This commit is contained in:
parent
3cb7fe5012
commit
9bb1bc5a3e
|
@ -1154,7 +1154,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders, Dictionary<Guid, Guid> refreshQueue)
|
private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders, HashSet<Guid> refreshQueue)
|
||||||
{
|
{
|
||||||
var info = new VirtualFolderInfo
|
var info = new VirtualFolderInfo
|
||||||
{
|
{
|
||||||
|
@ -1182,22 +1182,22 @@ namespace Emby.Server.Implementations.Library
|
||||||
};
|
};
|
||||||
|
|
||||||
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
|
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary))
|
|
||||||
{
|
|
||||||
info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (libraryFolder is not null)
|
if (libraryFolder is not null)
|
||||||
{
|
{
|
||||||
info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
var libraryFolderId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||||
|
info.ItemId = libraryFolderId;
|
||||||
|
if (libraryFolder.HasImage(ImageType.Primary))
|
||||||
|
{
|
||||||
|
info.PrimaryImageItemId = libraryFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
info.LibraryOptions = GetLibraryOptions(libraryFolder);
|
info.LibraryOptions = GetLibraryOptions(libraryFolder);
|
||||||
|
|
||||||
if (refreshQueue is not null)
|
if (refreshQueue is not null)
|
||||||
{
|
{
|
||||||
info.RefreshProgress = libraryFolder.GetRefreshProgress();
|
info.RefreshProgress = libraryFolder.GetRefreshProgress();
|
||||||
|
|
||||||
info.RefreshStatus = info.RefreshProgress.HasValue ? "Active" : refreshQueue.ContainsKey(libraryFolder.Id) ? "Queued" : "Idle";
|
info.RefreshStatus = info.RefreshProgress.HasValue ? "Active" : refreshQueue.Contains(libraryFolder.Id) ? "Queued" : "Idle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
/// <returns>Task{HttpResponseInfo}.</returns>
|
/// <returns>Task{HttpResponseInfo}.</returns>
|
||||||
Task<HttpResponseMessage> GetSearchImage(string providerName, string url, CancellationToken cancellationToken);
|
Task<HttpResponseMessage> GetSearchImage(string providerName, string url, CancellationToken cancellationToken);
|
||||||
|
|
||||||
Dictionary<Guid, Guid> GetRefreshQueue();
|
HashSet<Guid> GetRefreshQueue();
|
||||||
|
|
||||||
void OnRefreshStart(BaseItem item);
|
void OnRefreshStart(BaseItem item);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Priority_Queue;
|
|
||||||
using Book = MediaBrowser.Controller.Entities.Book;
|
using Book = MediaBrowser.Controller.Entities.Book;
|
||||||
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
|
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
|
||||||
using Movie = MediaBrowser.Controller.Entities.Movies.Movie;
|
using Movie = MediaBrowser.Controller.Entities.Movies.Movie;
|
||||||
|
@ -58,7 +57,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
private readonly IBaseItemManager _baseItemManager;
|
private readonly IBaseItemManager _baseItemManager;
|
||||||
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new();
|
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new();
|
||||||
private readonly CancellationTokenSource _disposeCancellationTokenSource = new();
|
private readonly CancellationTokenSource _disposeCancellationTokenSource = new();
|
||||||
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue = new();
|
private readonly PriorityQueue<(Guid ItemId, MetadataRefreshOptions RefreshOptions), RefreshPriority> _refreshQueue = new();
|
||||||
|
|
||||||
private IImageProvider[] _imageProviders = Array.Empty<IImageProvider>();
|
private IImageProvider[] _imageProviders = Array.Empty<IImageProvider>();
|
||||||
private IMetadataService[] _metadataServices = Array.Empty<IMetadataService>();
|
private IMetadataService[] _metadataServices = Array.Empty<IMetadataService>();
|
||||||
|
@ -897,18 +896,11 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Dictionary<Guid, Guid> GetRefreshQueue()
|
public HashSet<Guid> GetRefreshQueue()
|
||||||
{
|
{
|
||||||
lock (_refreshQueueLock)
|
lock (_refreshQueueLock)
|
||||||
{
|
{
|
||||||
var dict = new Dictionary<Guid, Guid>();
|
return _refreshQueue.UnorderedItems.Select(x => x.Element.ItemId).ToHashSet();
|
||||||
|
|
||||||
foreach (var item in _refreshQueue)
|
|
||||||
{
|
|
||||||
dict[item.Item1] = item.Item1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -969,7 +961,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_refreshQueue.Enqueue(new Tuple<Guid, MetadataRefreshOptions>(itemId, options), (int)priority);
|
_refreshQueue.Enqueue((itemId, options), priority);
|
||||||
|
|
||||||
lock (_refreshQueueLock)
|
lock (_refreshQueueLock)
|
||||||
{
|
{
|
||||||
|
@ -992,7 +984,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
var cancellationToken = _disposeCancellationTokenSource.Token;
|
var cancellationToken = _disposeCancellationTokenSource.Token;
|
||||||
|
|
||||||
while (_refreshQueue.TryDequeue(out Tuple<Guid, MetadataRefreshOptions> refreshItem))
|
while (_refreshQueue.TryDequeue(out var refreshItem, out _))
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
{
|
{
|
||||||
|
@ -1001,15 +993,15 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = libraryManager.GetItemById(refreshItem.Item1);
|
var item = libraryManager.GetItemById(refreshItem.ItemId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var task = item is MusicArtist artist
|
var task = item is MusicArtist artist
|
||||||
? RefreshArtist(artist, refreshItem.Item2, cancellationToken)
|
? RefreshArtist(artist, refreshItem.RefreshOptions, cancellationToken)
|
||||||
: RefreshItem(item, refreshItem.Item2, cancellationToken);
|
: RefreshItem(item, refreshItem.RefreshOptions, cancellationToken);
|
||||||
|
|
||||||
await task.ConfigureAwait(false);
|
await task.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||||
<PackageReference Include="OptimizedPriorityQueue" Version="5.1.0" />
|
|
||||||
<PackageReference Include="PlaylistsNET" Version="1.2.1" />
|
<PackageReference Include="PlaylistsNET" Version="1.2.1" />
|
||||||
<PackageReference Include="TagLibSharp" Version="2.3.0" />
|
<PackageReference Include="TagLibSharp" Version="2.3.0" />
|
||||||
<PackageReference Include="TMDbLib" Version="1.9.2" />
|
<PackageReference Include="TMDbLib" Version="1.9.2" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user