mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-10-25 05:42:10 +00:00
Backport pull request #18196 from jellyfin/release-12.z
Skip statistics on an empty library and refresh them after every scan
Original-merge: 83b89218e5
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
parent
3142fcd12f
commit
c5f5377e00
4 changed files with 246 additions and 13 deletions
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Database.Implementations;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
||||
namespace Emby.Server.Implementations.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the database statistics after every library scan.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The scheduled optimization skips itself while a scan runs, so without this the first scan of a new server
|
||||
/// leaves every query planned for an empty library until the next scheduled run.
|
||||
/// </remarks>
|
||||
public class RefreshDatabaseStatisticsPostScanTask : ILibraryPostScanTask
|
||||
{
|
||||
private readonly IJellyfinDatabaseProvider _databaseProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RefreshDatabaseStatisticsPostScanTask"/> class.
|
||||
/// </summary>
|
||||
/// <param name="databaseProvider">The database provider.</param>
|
||||
public RefreshDatabaseStatisticsPostScanTask(IJellyfinDatabaseProvider databaseProvider)
|
||||
{
|
||||
_databaseProvider = databaseProvider;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
await _databaseProvider.RefreshStatistics(cancellationToken).ConfigureAwait(false);
|
||||
progress.Report(100);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue