| | | 1 | | using System; |
| | | 2 | | using System.Threading; |
| | | 3 | | using System.Threading.Tasks; |
| | | 4 | | using Jellyfin.Database.Implementations; |
| | | 5 | | using MediaBrowser.Controller.Library; |
| | | 6 | | |
| | | 7 | | namespace Emby.Server.Implementations.Data; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Refreshes the database statistics after every library scan. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <remarks> |
| | | 13 | | /// The scheduled optimization skips itself while a scan runs, so without this the first scan of a new server |
| | | 14 | | /// leaves every query planned for an empty library until the next scheduled run. |
| | | 15 | | /// </remarks> |
| | | 16 | | public class RefreshDatabaseStatisticsPostScanTask : ILibraryPostScanTask |
| | | 17 | | { |
| | | 18 | | private readonly IJellyfinDatabaseProvider _databaseProvider; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Initializes a new instance of the <see cref="RefreshDatabaseStatisticsPostScanTask"/> class. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="databaseProvider">The database provider.</param> |
| | | 24 | | public RefreshDatabaseStatisticsPostScanTask(IJellyfinDatabaseProvider databaseProvider) |
| | | 25 | | { |
| | 27 | 26 | | _databaseProvider = databaseProvider; |
| | 27 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public async Task Run(IProgress<double> progress, CancellationToken cancellationToken) |
| | | 31 | | { |
| | 20 | 32 | | await _databaseProvider.RefreshStatistics(cancellationToken).ConfigureAwait(false); |
| | 20 | 33 | | progress.Report(100); |
| | 20 | 34 | | } |
| | | 35 | | } |