jellyfin/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs

72 lines
2.5 KiB
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2013-02-21 02:33:05 +01:00
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.Library;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Globalization;
2021-04-17 12:37:55 +02:00
using MediaBrowser.Model.Tasks;
2013-02-21 02:33:05 +01:00
2021-12-15 18:25:36 +01:00
namespace Emby.Server.Implementations.ScheduledTasks.Tasks
2013-02-21 02:33:05 +01:00
{
/// <summary>
2019-08-29 09:14:50 +02:00
/// Class RefreshMediaLibraryTask.
2013-02-21 02:33:05 +01:00
/// </summary>
public class RefreshMediaLibraryTask : IScheduledTask
2013-02-21 02:33:05 +01:00
{
/// <summary>
/// The _library manager.
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILocalizationManager _localization;
2013-02-23 08:57:11 +01:00
/// <summary>
/// Initializes a new instance of the <see cref="RefreshMediaLibraryTask" /> class.
/// </summary>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
2022-01-10 16:25:46 +01:00
public RefreshMediaLibraryTask(ILibraryManager libraryManager, ILocalizationManager localization)
2013-02-23 08:57:11 +01:00
{
_libraryManager = libraryManager;
2020-03-26 22:26:25 +01:00
_localization = localization;
2013-02-23 08:57:11 +01:00
}
2021-10-02 18:53:51 +02:00
/// <inheritdoc />
public string Name => _localization.GetLocalizedString("TaskRefreshLibrary");
/// <inheritdoc />
public string Description => _localization.GetLocalizedString("TaskRefreshLibraryDescription");
/// <inheritdoc />
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
/// <inheritdoc />
public string Key => "RefreshLibrary";
2013-02-21 02:33:05 +01:00
/// <summary>
2019-08-29 09:14:50 +02:00
/// Creates the triggers that define when the task will run.
2013-02-21 02:33:05 +01:00
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
2013-02-21 02:33:05 +01:00
{
2019-08-29 09:14:50 +02:00
yield return new TaskTriggerInfo
{
2020-03-24 16:12:06 +01:00
Type = TaskTriggerInfo.TriggerInterval,
IntervalTicks = TimeSpan.FromHours(12).Ticks
};
2013-02-21 02:33:05 +01:00
}
2022-02-15 18:59:46 +01:00
/// <inheritdoc />
public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
2013-02-21 02:33:05 +01:00
{
cancellationToken.ThrowIfCancellationRequested();
2013-02-22 05:23:06 +01:00
progress.Report(0);
2013-02-21 02:33:05 +01:00
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
2013-02-21 02:33:05 +01:00
}
}
}