2020-05-29 09:28:19 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 19:54:44 +00:00
|
|
|
using System;
|
2013-02-21 01:33:05 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
2016-11-03 06:37:52 +00:00
|
|
|
using Emby.Server.Implementations.Library;
|
2019-01-13 19:22:24 +00:00
|
|
|
using MediaBrowser.Controller.Library;
|
2020-03-26 19:28:30 +00:00
|
|
|
using MediaBrowser.Model.Globalization;
|
2021-04-17 10:37:55 +00:00
|
|
|
using MediaBrowser.Model.Tasks;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
2021-12-15 17:25:36 +00:00
|
|
|
namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
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>
|
2016-10-23 19:14:57 +00:00
|
|
|
public class RefreshMediaLibraryTask : IScheduledTask
|
2013-02-21 01:33:05 +00:00
|
|
|
{
|
2013-02-26 03:43:04 +00:00
|
|
|
/// <summary>
|
2020-05-29 09:28:19 +00:00
|
|
|
/// The _library manager.
|
2013-02-26 03:43:04 +00:00
|
|
|
/// </summary>
|
2013-02-28 19:32:41 +00:00
|
|
|
private readonly ILibraryManager _libraryManager;
|
2020-03-26 19:28:30 +00:00
|
|
|
private readonly ILocalizationManager _localization;
|
2013-02-26 03:43:04 +00:00
|
|
|
|
2013-02-23 07:57:11 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="RefreshMediaLibraryTask" /> class.
|
|
|
|
/// </summary>
|
2021-08-17 16:35:26 +00:00
|
|
|
/// <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 15:25:46 +00:00
|
|
|
public RefreshMediaLibraryTask(ILibraryManager libraryManager, ILocalizationManager localization)
|
2013-02-23 07:57:11 +00:00
|
|
|
{
|
2013-02-28 19:32:41 +00:00
|
|
|
_libraryManager = libraryManager;
|
2020-03-26 21:26:25 +00:00
|
|
|
_localization = localization;
|
2013-02-23 07:57:11 +00:00
|
|
|
}
|
|
|
|
|
2021-10-02 16:53:51 +00: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 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>
|
2016-10-23 19:14:57 +00:00
|
|
|
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
|
2016-10-23 19:14:57 +00:00
|
|
|
};
|
2013-02-21 01:33:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 17:59:46 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
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
|
|
|
|
2013-04-14 19:39:25 +00:00
|
|
|
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
|
2013-02-21 01:33:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|