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