Fix warnings in ScheduledTasks

pull/6648/head
Patrick Barron 3 years ago
parent 5043a887cc
commit 4ba9b6c305

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

@ -19,16 +19,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary>
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>
/// The _task queue.
/// </summary>
@ -53,10 +43,20 @@ namespace Emby.Server.Implementations.ScheduledTasks
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>
/// Cancels if running and queue.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">The task type.</typeparam>
/// <param name="options">Task options.</param>
public void CancelIfRunningAndQueue<T>(TaskOptions options)
where T : IScheduledTask
@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary>
/// Cancels if running.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">The task type.</typeparam>
public void CancelIfRunning<T>()
where T : IScheduledTask
{
@ -87,7 +87,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">The task type.</typeparam>
/// <param name="options">Task options.</param>
public void QueueScheduledTask<T>(TaskOptions options)
where T : IScheduledTask

@ -39,6 +39,12 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary>
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
/// </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(
ILibraryManager libraryManager,
IItemRepository itemRepo,

@ -22,6 +22,9 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <summary>
/// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class.
/// </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(
ILogger<OptimizeDatabaseTask> logger,
ILocalizationManager localization,

@ -32,9 +32,24 @@ namespace Emby.Server.Implementations.ScheduledTasks
_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>
/// Creates the triggers that define when the task will run.
/// </summary>
/// <returns>An <see cref="IEnumerable{TaskTriggerInfo}"/> containing the default trigger infos for this task.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new[]
@ -57,19 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
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;
}
}

@ -33,6 +33,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
_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>
/// Creates the triggers that define when the task will run.
/// </summary>
@ -60,26 +72,5 @@ namespace Emby.Server.Implementations.ScheduledTasks
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;
}
}

Loading…
Cancel
Save