Fix warnings in ScheduledTasks

This commit is contained in:
Patrick Barron 2021-10-02 12:53:51 -04:00
parent 5043a887cc
commit 4ba9b6c305
6 changed files with 56 additions and 55 deletions

View File

@ -10,9 +10,9 @@ using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Data.Events; using Jellyfin.Data.Events;
using Jellyfin.Extensions.Json;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using Jellyfin.Extensions.Json;
using MediaBrowser.Common.Progress; using MediaBrowser.Common.Progress;
using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -24,6 +24,11 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
public class ScheduledTaskWorker : IScheduledTaskWorker public class ScheduledTaskWorker : IScheduledTaskWorker
{ {
/// <summary>
/// The options for the json Serializer.
/// </summary>
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
/// <summary> /// <summary>
/// Gets or sets the application paths. /// Gets or sets the application paths.
/// </summary> /// </summary>
@ -66,11 +71,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
private string _id; private string _id;
/// <summary>
/// The options for the json Serializer.
/// </summary>
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class. /// Initializes a new instance of the <see cref="ScheduledTaskWorker" /> class.
/// </summary> /// </summary>
@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
/// <param name="options">Task options.</param> /// <param name="options">Task options.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
/// <exception cref="InvalidOperationException">Cannot execute a Task that is already running</exception> /// <exception cref="InvalidOperationException">Cannot execute a Task that is already running.</exception>
public async Task Execute(TaskOptions options) public async Task Execute(TaskOptions options)
{ {
var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false)); var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false));

View File

@ -19,16 +19,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary> /// </summary>
public class TaskManager : ITaskManager public class TaskManager : ITaskManager
{ {
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
public event EventHandler<TaskCompletionEventArgs> TaskCompleted;
/// <summary>
/// Gets the list of Scheduled Tasks.
/// </summary>
/// <value>The scheduled tasks.</value>
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
/// <summary> /// <summary>
/// The _task queue. /// The _task queue.
/// </summary> /// </summary>
@ -53,10 +43,20 @@ namespace Emby.Server.Implementations.ScheduledTasks
ScheduledTasks = Array.Empty<IScheduledTaskWorker>(); ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
} }
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>> TaskExecuting;
public event EventHandler<TaskCompletionEventArgs> TaskCompleted;
/// <summary>
/// Gets the list of Scheduled Tasks.
/// </summary>
/// <value>The scheduled tasks.</value>
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
/// <summary> /// <summary>
/// Cancels if running and queue. /// Cancels if running and queue.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">The task type.</typeparam>
/// <param name="options">Task options.</param> /// <param name="options">Task options.</param>
public void CancelIfRunningAndQueue<T>(TaskOptions options) public void CancelIfRunningAndQueue<T>(TaskOptions options)
where T : IScheduledTask where T : IScheduledTask
@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary> /// <summary>
/// Cancels if running. /// Cancels if running.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">The task type.</typeparam>
public void CancelIfRunning<T>() public void CancelIfRunning<T>()
where T : IScheduledTask where T : IScheduledTask
{ {
@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary> /// <summary>
/// Queues the scheduled task. /// Queues the scheduled task.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T">The task type.</typeparam>
/// <param name="options">Task options.</param> /// <param name="options">Task options.</param>
public void QueueScheduledTask<T>(TaskOptions options) public void QueueScheduledTask<T>(TaskOptions options)
where T : IScheduledTask where T : IScheduledTask

View File

@ -39,6 +39,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class. /// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
/// </summary> /// </summary>
/// <param name="libraryManager">The library manager.</param>.
/// <param name="itemRepo">The item repository.</param>
/// <param name="appPaths">The application paths.</param>
/// <param name="encodingManager">The encoding manager.</param>
/// <param name="fileSystem">The filesystem.</param>
/// <param name="localization">The localization manager.</param>
public ChapterImagesTask( public ChapterImagesTask(
ILibraryManager libraryManager, ILibraryManager libraryManager,
IItemRepository itemRepo, IItemRepository itemRepo,

View File

@ -22,6 +22,9 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class. /// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class.
/// </summary> /// </summary>
/// <param name="logger">The logger.</param>
/// <param name="localization">The localization manager.</param>
/// <param name="provider">The jellyfin DB context provider.</param>
public OptimizeDatabaseTask( public OptimizeDatabaseTask(
ILogger<OptimizeDatabaseTask> logger, ILogger<OptimizeDatabaseTask> logger,
ILocalizationManager localization, ILocalizationManager localization,

View File

@ -32,9 +32,24 @@ namespace Emby.Server.Implementations.ScheduledTasks
_localization = localization; _localization = localization;
} }
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
public string Key => "RefreshPeople";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
/// <summary> /// <summary>
/// Creates the triggers that define when the task will run. /// Creates the triggers that define when the task will run.
/// </summary> /// </summary>
/// <returns>An <see cref="IEnumerable{TaskTriggerInfo}"/> containing the default trigger infos for this task.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{ {
return new[] return new[]
@ -57,19 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
{ {
return _libraryManager.ValidatePeople(cancellationToken, progress); return _libraryManager.ValidatePeople(cancellationToken, progress);
} }
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
public string Key => "RefreshPeople";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
} }
} }

View File

@ -33,6 +33,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
_localization = localization; _localization = localization;
} }
/// <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";
/// <summary> /// <summary>
/// Creates the triggers that define when the task will run. /// Creates the triggers that define when the task will run.
/// </summary> /// </summary>
@ -60,26 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken); return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
} }
/// <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";
/// <inheritdoc />
public bool IsHidden => false;
/// <inheritdoc />
public bool IsEnabled => true;
/// <inheritdoc />
public bool IsLogged => true;
} }
} }