| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Threading; |
| | | 4 | | using System.Threading.Tasks; |
| | | 5 | | using Emby.Server.Implementations.Library; |
| | | 6 | | using MediaBrowser.Controller.Library; |
| | | 7 | | using MediaBrowser.Model.Globalization; |
| | | 8 | | using MediaBrowser.Model.Tasks; |
| | | 9 | | |
| | | 10 | | namespace Emby.Server.Implementations.ScheduledTasks.Tasks; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Class RefreshMediaLibraryTask. |
| | | 14 | | /// </summary> |
| | | 15 | | public class RefreshMediaLibraryTask : IScheduledTask |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// The _library manager. |
| | | 19 | | /// </summary> |
| | | 20 | | private readonly ILibraryManager _libraryManager; |
| | | 21 | | private readonly ILocalizationManager _localization; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Initializes a new instance of the <see cref="RefreshMediaLibraryTask" /> class. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param> |
| | | 27 | | /// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param> |
| | | 28 | | public RefreshMediaLibraryTask(ILibraryManager libraryManager, ILocalizationManager localization) |
| | | 29 | | { |
| | 21 | 30 | | _libraryManager = libraryManager; |
| | 21 | 31 | | _localization = localization; |
| | 21 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <inheritdoc /> |
| | 102 | 35 | | public string Name => _localization.GetLocalizedString("TaskRefreshLibrary"); |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | 0 | 38 | | public string Description => _localization.GetLocalizedString("TaskRefreshLibraryDescription"); |
| | | 39 | | |
| | | 40 | | /// <inheritdoc /> |
| | 0 | 41 | | public string Category => _localization.GetLocalizedString("TasksLibraryCategory"); |
| | | 42 | | |
| | | 43 | | /// <inheritdoc /> |
| | 23 | 44 | | public string Key => "RefreshLibrary"; |
| | | 45 | | |
| | | 46 | | /// <inheritdoc /> |
| | | 47 | | public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() |
| | | 48 | | { |
| | | 49 | | yield return new TaskTriggerInfo |
| | | 50 | | { |
| | | 51 | | Type = TaskTriggerInfoType.IntervalTrigger, |
| | | 52 | | IntervalTicks = TimeSpan.FromHours(12).Ticks |
| | | 53 | | }; |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <inheritdoc /> |
| | | 57 | | public async Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken) |
| | | 58 | | { |
| | | 59 | | cancellationToken.ThrowIfCancellationRequested(); |
| | | 60 | | |
| | | 61 | | progress.Report(0); |
| | | 62 | | |
| | | 63 | | await ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken).ConfigureAwait |
| | | 64 | | } |
| | | 65 | | } |