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

86 lines
2.8 KiB
C#
Raw Normal View History

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