aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs
diff options
context:
space:
mode:
authorKGT1 <kilian.gamn@gmx.de>2026-10-17 16:51:55 +0200
committerGitHub <noreply@github.com>2026-10-17 16:51:55 +0200
commit292b13d1daf36316274211a8b3c13385c60efdb5 (patch)
tree1204df8423af2f317dbf3171aa7a42b1413b4e2e /Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs
parent0be145c4e202bac0edc36b769f8b4db2232ad216 (diff)
parent08c2ba6e0b6499122822f1c5b18bc426104538b4 (diff)
Merge branch 'jellyfin:master' into removeGenericConfigurationEndpoint
Diffstat (limited to 'Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs')
-rw-r--r--Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs b/Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs
new file mode 100644
index 0000000000..be1fe660c9
--- /dev/null
+++ b/Emby.Server.Implementations/Data/RefreshDatabaseStatisticsPostScanTask.cs
@@ -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);
+ }
+}