Cleanup tasks
This commit is contained in:
parent
737a1b8a37
commit
08ed0a9a5d
|
@ -1,8 +1,7 @@
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -24,51 +23,15 @@ 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;
|
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the application paths.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The application paths.</value>
|
|
||||||
private readonly IApplicationPaths _applicationPaths;
|
private readonly IApplicationPaths _applicationPaths;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the logger.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The logger.</value>
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the task manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The task manager.</value>
|
|
||||||
private readonly ITaskManager _taskManager;
|
private readonly ITaskManager _taskManager;
|
||||||
|
private readonly object _lastExecutionResultSyncLock = new();
|
||||||
/// <summary>
|
private bool _readFromFile;
|
||||||
/// The _last execution result sync lock.
|
|
||||||
/// </summary>
|
|
||||||
private readonly object _lastExecutionResultSyncLock = new object();
|
|
||||||
|
|
||||||
private bool _readFromFile = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _last execution result.
|
|
||||||
/// </summary>
|
|
||||||
private TaskResult _lastExecutionResult;
|
private TaskResult _lastExecutionResult;
|
||||||
|
|
||||||
private Task _currentTask;
|
private Task _currentTask;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _triggers.
|
|
||||||
/// </summary>
|
|
||||||
private Tuple<TaskTriggerInfo, ITaskTrigger>[] _triggers;
|
private Tuple<TaskTriggerInfo, ITaskTrigger>[] _triggers;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _id.
|
|
||||||
/// </summary>
|
|
||||||
private string _id;
|
private string _id;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -104,18 +67,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
InitTriggerEvents();
|
InitTriggerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<GenericEventArgs<double>> TaskProgress;
|
public event EventHandler<GenericEventArgs<double>> TaskProgress;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the scheduled task.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The scheduled task.</value>
|
|
||||||
public IScheduledTask ScheduledTask { get; private set; }
|
public IScheduledTask ScheduledTask { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the last execution result.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The last execution result.</value>
|
|
||||||
public TaskResult LastExecutionResult
|
public TaskResult LastExecutionResult
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -169,22 +127,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The name.</value>
|
|
||||||
public string Name => ScheduledTask.Name;
|
public string Name => ScheduledTask.Name;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the description.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The description.</value>
|
|
||||||
public string Description => ScheduledTask.Description;
|
public string Description => ScheduledTask.Description;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the category.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The category.</value>
|
|
||||||
public string Category => ScheduledTask.Category;
|
public string Category => ScheduledTask.Category;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -199,10 +148,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
/// <value>The current execution start time.</value>
|
/// <value>The current execution start time.</value>
|
||||||
private DateTime CurrentExecutionStartTime { get; set; }
|
private DateTime CurrentExecutionStartTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the state.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The state.</value>
|
|
||||||
public TaskState State
|
public TaskState State
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -218,10 +164,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the current progress.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The current progress.</value>
|
|
||||||
public double? CurrentProgress { get; private set; }
|
public double? CurrentProgress { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -247,12 +190,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets or sets the triggers that define when the task will run.
|
public IReadOnlyList<TaskTriggerInfo> Triggers
|
||||||
/// </summary>
|
|
||||||
/// <value>The triggers.</value>
|
|
||||||
/// <exception cref="ArgumentNullException"><c>value</c> is <c>null</c>.</exception>
|
|
||||||
public TaskTriggerInfo[] Triggers
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -272,10 +211,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the unique id.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The unique id.</value>
|
|
||||||
public string Id
|
public string Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -290,6 +226,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
ReloadTriggerEvents(true);
|
ReloadTriggerEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void ReloadTriggerEvents()
|
public void ReloadTriggerEvents()
|
||||||
{
|
{
|
||||||
ReloadTriggerEvents(false);
|
ReloadTriggerEvents(false);
|
||||||
|
@ -529,14 +466,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return new TaskTriggerInfo[]
|
return
|
||||||
{
|
[
|
||||||
new TaskTriggerInfo
|
new()
|
||||||
{
|
{
|
||||||
IntervalTicks = TimeSpan.FromDays(1).Ticks,
|
IntervalTicks = TimeSpan.FromDays(1).Ticks,
|
||||||
Type = TaskTriggerInfo.TriggerInterval
|
Type = TaskTriggerInfo.TriggerInterval
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,9 +526,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
((TaskManager)_taskManager).OnTaskCompleted(this, result);
|
((TaskManager)_taskManager).OnTaskCompleted(this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -41,21 +39,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
|
ScheduledTasks = Array.Empty<IScheduledTaskWorker>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
public event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
public event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the list of Scheduled Tasks.
|
public IReadOnlyList<IScheduledTaskWorker> ScheduledTasks { get; private set; }
|
||||||
/// </summary>
|
|
||||||
/// <value>The scheduled tasks.</value>
|
|
||||||
public IScheduledTaskWorker[] ScheduledTasks { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Cancels if running and queue.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The task type.</typeparam>
|
|
||||||
/// <param name="options">Task options.</param>
|
|
||||||
public void CancelIfRunningAndQueue<T>(TaskOptions options)
|
public void CancelIfRunningAndQueue<T>(TaskOptions options)
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -65,16 +58,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
QueueScheduledTask<T>(options);
|
QueueScheduledTask<T>(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void CancelIfRunningAndQueue<T>()
|
public void CancelIfRunningAndQueue<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
CancelIfRunningAndQueue<T>(new TaskOptions());
|
CancelIfRunningAndQueue<T>(new TaskOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Cancels if running.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The task type.</typeparam>
|
|
||||||
public void CancelIfRunning<T>()
|
public void CancelIfRunning<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -82,11 +73,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
((ScheduledTaskWorker)task).CancelIfRunning();
|
((ScheduledTaskWorker)task).CancelIfRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Queues the scheduled task.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The task type.</typeparam>
|
|
||||||
/// <param name="options">Task options.</param>
|
|
||||||
public void QueueScheduledTask<T>(TaskOptions options)
|
public void QueueScheduledTask<T>(TaskOptions options)
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -102,12 +89,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void QueueScheduledTask<T>()
|
public void QueueScheduledTask<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
QueueScheduledTask<T>(new TaskOptions());
|
QueueScheduledTask<T>(new TaskOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void QueueIfNotRunning<T>()
|
public void QueueIfNotRunning<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -119,6 +108,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void Execute<T>()
|
public void Execute<T>()
|
||||||
where T : IScheduledTask
|
where T : IScheduledTask
|
||||||
{
|
{
|
||||||
|
@ -144,11 +134,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Queues the scheduled task.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="task">The task.</param>
|
|
||||||
/// <param name="options">The task options.</param>
|
|
||||||
public void QueueScheduledTask(IScheduledTask task, TaskOptions options)
|
public void QueueScheduledTask(IScheduledTask task, TaskOptions options)
|
||||||
{
|
{
|
||||||
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType());
|
var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == task.GetType());
|
||||||
|
@ -186,10 +172,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Adds the tasks.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="tasks">The tasks.</param>
|
|
||||||
public void AddTasks(IEnumerable<IScheduledTask> tasks)
|
public void AddTasks(IEnumerable<IScheduledTask> tasks)
|
||||||
{
|
{
|
||||||
var list = tasks.Select(t => new ScheduledTaskWorker(t, _applicationPaths, this, _logger));
|
var list = tasks.Select(t => new ScheduledTaskWorker(t, _applicationPaths, this, _logger));
|
||||||
|
@ -197,9 +180,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
ScheduledTasks = ScheduledTasks.Concat(list).ToArray();
|
ScheduledTasks = ScheduledTasks.Concat(list).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -218,11 +199,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void Cancel(IScheduledTaskWorker task)
|
public void Cancel(IScheduledTaskWorker task)
|
||||||
{
|
{
|
||||||
((ScheduledTaskWorker)task).Cancel();
|
((ScheduledTaskWorker)task).Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public Task Execute(IScheduledTaskWorker task, TaskOptions options)
|
public Task Execute(IScheduledTaskWorker task, TaskOptions options)
|
||||||
{
|
{
|
||||||
return ((ScheduledTaskWorker)task).Execute(options);
|
return ((ScheduledTaskWorker)task).Execute(options);
|
||||||
|
|
|
@ -142,7 +142,7 @@ public partial class AudioNormalizationTask : IScheduledTask
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.LUFS = await CalculateLUFSAsync(string.Format(CultureInfo.InvariantCulture, "-i \"{0}\"", t.Path.Replace("\"", "\\\"", StringComparison.Ordinal)), cancellationToken);
|
t.LUFS = await CalculateLUFSAsync(string.Format(CultureInfo.InvariantCulture, "-i \"{0}\"", t.Path.Replace("\"", "\\\"", StringComparison.Ordinal)), cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_itemRepository.SaveItems(tracks, cancellationToken);
|
_itemRepository.SaveItems(tracks, cancellationToken);
|
||||||
|
|
|
@ -36,13 +36,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <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="logger">The logger.</param>.
|
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
|
||||||
/// <param name="libraryManager">The library manager.</param>.
|
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
||||||
/// <param name="itemRepo">The item repository.</param>
|
/// <param name="itemRepo">Instance of the <see cref="IItemRepository"/> interface.</param>
|
||||||
/// <param name="appPaths">The application paths.</param>
|
/// <param name="appPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
|
||||||
/// <param name="encodingManager">The encoding manager.</param>
|
/// <param name="encodingManager">Instance of the <see cref="IEncodingManager"/> interface.</param>
|
||||||
/// <param name="fileSystem">The filesystem.</param>
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
||||||
/// <param name="localization">The localization manager.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
public ChapterImagesTask(
|
public ChapterImagesTask(
|
||||||
ILogger<ChapterImagesTask> logger,
|
ILogger<ChapterImagesTask> logger,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
|
@ -76,15 +76,15 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return
|
||||||
{
|
[
|
||||||
new TaskTriggerInfo
|
new TaskTriggerInfo
|
||||||
{
|
{
|
||||||
Type = TaskTriggerInfo.TriggerDaily,
|
Type = TaskTriggerInfo.TriggerDaily,
|
||||||
TimeOfDayTicks = TimeSpan.FromHours(2).Ticks,
|
TimeOfDayTicks = TimeSpan.FromHours(2).Ticks,
|
||||||
MaxRuntimeTicks = TimeSpan.FromHours(4).Ticks
|
MaxRuntimeTicks = TimeSpan.FromHours(4).Ticks
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -92,18 +92,18 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
{
|
{
|
||||||
var videos = _libraryManager.GetItemList(new InternalItemsQuery
|
var videos = _libraryManager.GetItemList(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
MediaTypes = new[] { MediaType.Video },
|
MediaTypes = [MediaType.Video],
|
||||||
IsFolder = false,
|
IsFolder = false,
|
||||||
Recursive = true,
|
Recursive = true,
|
||||||
DtoOptions = new DtoOptions(false)
|
DtoOptions = new DtoOptions(false)
|
||||||
{
|
{
|
||||||
EnableImages = false
|
EnableImages = false
|
||||||
},
|
},
|
||||||
SourceTypes = new SourceType[] { SourceType.Library },
|
SourceTypes = [SourceType.Library],
|
||||||
IsVirtualItem = false
|
IsVirtualItem = false
|
||||||
})
|
})
|
||||||
.OfType<Video>()
|
.OfType<Video>()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -72,7 +71,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return Enumerable.Empty<TaskTriggerInfo>();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
|
||||||
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
/// <param name="collectionManager">Instance of the <see cref="ICollectionManager"/> interface.</param>
|
/// <param name="collectionManager">Instance of the <see cref="ICollectionManager"/> interface.</param>
|
||||||
/// <param name="playlistManager">Instance of the <see cref="IPlaylistManager"/> interface.</param>
|
/// <param name="playlistManager">Instance of the <see cref="IPlaylistManager"/> interface.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
|
||||||
/// <param name="providerManager">The provider manager.</param>
|
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
|
||||||
/// <param name="fileSystem">The filesystem.</param>
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
||||||
public CleanupCollectionAndPlaylistPathsTask(
|
public CleanupCollectionAndPlaylistPathsTask(
|
||||||
ILocalizationManager localization,
|
ILocalizationManager localization,
|
||||||
ICollectionManager collectionManager,
|
ICollectionManager collectionManager,
|
||||||
|
@ -135,6 +135,6 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[] { new TaskTriggerInfo() { Type = TaskTriggerInfo.TriggerStartup } };
|
return [new TaskTriggerInfo() { Type = TaskTriggerInfo.TriggerStartup }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,17 +67,14 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates the triggers that define when the task will run.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return
|
||||||
{
|
[
|
||||||
// Every so often
|
// Every so often
|
||||||
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DeleteLogFileTask" /> class.
|
/// Initializes a new instance of the <see cref="DeleteLogFileTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">Instance of the <see cref="IConfigurationManager"/> interface.</param>
|
||||||
/// <param name="fileSystem">The file system.</param>
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
||||||
/// <param name="localization">The localization manager.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
public DeleteLogFileTask(IConfigurationManager configurationManager, IFileSystem fileSystem, ILocalizationManager localization)
|
public DeleteLogFileTask(IConfigurationManager configurationManager, IFileSystem fileSystem, ILocalizationManager localization)
|
||||||
{
|
{
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
|
@ -57,16 +57,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates the triggers that define when the task will run.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return
|
||||||
{
|
[
|
||||||
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -65,8 +65,12 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return
|
||||||
{
|
[
|
||||||
|
new TaskTriggerInfo
|
||||||
|
{
|
||||||
|
Type = TaskTriggerInfo.TriggerStartup
|
||||||
|
},
|
||||||
new TaskTriggerInfo
|
new TaskTriggerInfo
|
||||||
{
|
{
|
||||||
Type = TaskTriggerInfo.TriggerStartup
|
Type = TaskTriggerInfo.TriggerStartup
|
||||||
|
@ -76,7 +80,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
Type = TaskTriggerInfo.TriggerInterval,
|
Type = TaskTriggerInfo.TriggerInterval,
|
||||||
IntervalTicks = TimeSpan.FromHours(24).Ticks
|
IntervalTicks = TimeSpan.FromHours(24).Ticks
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -22,9 +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="logger">Instance of the <see cref="ILogger"/> interface.</param>
|
||||||
/// <param name="localization">The localization manager.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
/// <param name="provider">The jellyfin DB context provider.</param>
|
/// <param name="provider">Instance of the <see cref="IDbContextFactory{JellyfinDbContext}"/> interface.</param>
|
||||||
public OptimizeDatabaseTask(
|
public OptimizeDatabaseTask(
|
||||||
ILogger<OptimizeDatabaseTask> logger,
|
ILogger<OptimizeDatabaseTask> logger,
|
||||||
ILocalizationManager localization,
|
ILocalizationManager localization,
|
||||||
|
@ -56,17 +56,14 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates the triggers that define when the task will run.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
return new[]
|
return
|
||||||
{
|
[
|
||||||
// Every so often
|
// Every so often
|
||||||
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -13,37 +11,41 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class PeopleValidationTask.
|
/// Class PeopleValidationTask.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PeopleValidationTask : IScheduledTask
|
public class PeopleValidationTask : IScheduledTask, IConfigurableScheduledTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The library manager.
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
|
/// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="libraryManager">The library manager.</param>
|
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
||||||
/// <param name="localization">The localization manager.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
public PeopleValidationTask(ILibraryManager libraryManager, ILocalizationManager localization)
|
public PeopleValidationTask(ILibraryManager libraryManager, ILocalizationManager localization)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
|
public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
|
public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Key => "RefreshPeople";
|
public string Key => "RefreshPeople";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsHidden => false;
|
public bool IsHidden => false;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsEnabled => true;
|
public bool IsEnabled => true;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -19,14 +17,17 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask
|
public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The _logger.
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILogger<PluginUpdateTask> _logger;
|
private readonly ILogger<PluginUpdateTask> _logger;
|
||||||
|
|
||||||
private readonly IInstallationManager _installationManager;
|
private readonly IInstallationManager _installationManager;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PluginUpdateTask" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
|
||||||
|
/// <param name="installationManager">Instance of the <see cref="IInstallationManager"/> interface.</param>
|
||||||
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
public PluginUpdateTask(ILogger<PluginUpdateTask> logger, IInstallationManager installationManager, ILocalizationManager localization)
|
public PluginUpdateTask(ILogger<PluginUpdateTask> logger, IInstallationManager installationManager, ILocalizationManager localization)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
@ -55,10 +56,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates the triggers that define when the task will run.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
// At startup
|
// At startup
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -45,10 +43,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Key => "RefreshLibrary";
|
public string Key => "RefreshLibrary";
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Creates the triggers that define when the task will run.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
{
|
{
|
||||||
yield return new TaskTriggerInfo
|
yield return new TaskTriggerInfo
|
||||||
|
|
|
@ -25,23 +25,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
TaskOptions = taskOptions;
|
TaskOptions = taskOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when [triggered].
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<EventArgs>? Triggered;
|
public event EventHandler<EventArgs>? Triggered;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the options of this task.
|
|
||||||
/// </summary>
|
|
||||||
public TaskOptions TaskOptions { get; }
|
public TaskOptions TaskOptions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stars waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lastResult">The last result.</param>
|
|
||||||
/// <param name="logger">The logger.</param>
|
|
||||||
/// <param name="taskName">The name of the task.</param>
|
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
|
||||||
public void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
public void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
@ -58,9 +48,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
_timer = new Timer(_ => OnTriggered(), null, dueTime, TimeSpan.FromMilliseconds(-1));
|
_timer = new Timer(_ => OnTriggered(), null, dueTime, TimeSpan.FromMilliseconds(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stops waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
|
@ -12,7 +10,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class StartupTrigger : ITaskTrigger
|
public sealed class StartupTrigger : ITaskTrigger
|
||||||
{
|
{
|
||||||
public const int DelayMs = 3000;
|
private const int DelayMs = 3000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="StartupTrigger"/> class.
|
/// Initializes a new instance of the <see cref="StartupTrigger"/> class.
|
||||||
|
@ -23,23 +21,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
TaskOptions = taskOptions;
|
TaskOptions = taskOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when [triggered].
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<EventArgs>? Triggered;
|
public event EventHandler<EventArgs>? Triggered;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the options of this task.
|
|
||||||
/// </summary>
|
|
||||||
public TaskOptions TaskOptions { get; }
|
public TaskOptions TaskOptions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stars waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lastResult">The last result.</param>
|
|
||||||
/// <param name="logger">The logger.</param>
|
|
||||||
/// <param name="taskName">The name of the task.</param>
|
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
|
||||||
public async void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
public async void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
if (isApplicationStartup)
|
if (isApplicationStartup)
|
||||||
|
@ -50,9 +38,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stops waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
private readonly TimeSpan _timeOfDay;
|
private readonly TimeSpan _timeOfDay;
|
||||||
private readonly DayOfWeek _dayOfWeek;
|
private readonly DayOfWeek _dayOfWeek;
|
||||||
private Timer? _timer;
|
private Timer? _timer;
|
||||||
private bool _disposed = false;
|
private bool _disposed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="WeeklyTrigger"/> class.
|
/// Initializes a new instance of the <see cref="WeeklyTrigger"/> class.
|
||||||
|
@ -28,23 +28,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
TaskOptions = taskOptions;
|
TaskOptions = taskOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when [triggered].
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<EventArgs>? Triggered;
|
public event EventHandler<EventArgs>? Triggered;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the options of this task.
|
|
||||||
/// </summary>
|
|
||||||
public TaskOptions TaskOptions { get; }
|
public TaskOptions TaskOptions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stars waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="lastResult">The last result.</param>
|
|
||||||
/// <param name="logger">The logger.</param>
|
|
||||||
/// <param name="taskName">The name of the task.</param>
|
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
|
||||||
public void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
public void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
@ -81,9 +71,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
|
||||||
return triggerDate.Add(_timeOfDay);
|
return triggerDate.Add(_timeOfDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Stops waiting for the trigger action.
|
|
||||||
/// </summary>
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for configurable scheduled tasks.
|
||||||
|
/// </summary>
|
||||||
public interface IConfigurableScheduledTask
|
public interface IConfigurableScheduledTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,6 +17,10 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
|
||||||
bool IsEnabled { get; }
|
bool IsEnabled { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance is logged.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is logged; otherwise, <c>false</c>.</value>
|
||||||
bool IsLogged { get; }
|
bool IsLogged { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Jellyfin.Data.Events;
|
using Jellyfin.Data.Events;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
|
@ -60,7 +61,7 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// Gets or sets the triggers that define when the task will run.
|
/// Gets or sets the triggers that define when the task will run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The triggers.</value>
|
/// <value>The triggers.</value>
|
||||||
TaskTriggerInfo[] Triggers { get; set; }
|
IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the unique id.
|
/// Gets the unique id.
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -7,17 +5,26 @@ using Jellyfin.Data.Events;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for the TaskManager class.
|
||||||
|
/// </summary>
|
||||||
public interface ITaskManager : IDisposable
|
public interface ITaskManager : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event handler for task execution.
|
||||||
|
/// </summary>
|
||||||
event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event handler for task completion.
|
||||||
|
/// </summary>
|
||||||
event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of Scheduled Tasks.
|
/// Gets the list of Scheduled Tasks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The scheduled tasks.</value>
|
/// <value>The scheduled tasks.</value>
|
||||||
IScheduledTaskWorker[] ScheduledTasks { get; }
|
IReadOnlyList<IScheduledTaskWorker> ScheduledTasks { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels if running and queue.
|
/// Cancels if running and queue.
|
||||||
|
@ -56,6 +63,10 @@ namespace MediaBrowser.Model.Tasks
|
||||||
void QueueScheduledTask<T>()
|
void QueueScheduledTask<T>()
|
||||||
where T : IScheduledTask;
|
where T : IScheduledTask;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queues the scheduled task if it is not already running.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
||||||
void QueueIfNotRunning<T>()
|
void QueueIfNotRunning<T>()
|
||||||
where T : IScheduledTask;
|
where T : IScheduledTask;
|
||||||
|
|
||||||
|
@ -72,10 +83,24 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// <param name="tasks">The tasks.</param>
|
/// <param name="tasks">The tasks.</param>
|
||||||
void AddTasks(IEnumerable<IScheduledTask> tasks);
|
void AddTasks(IEnumerable<IScheduledTask> tasks);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the tasks.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task">The tasks.</param>
|
||||||
void Cancel(IScheduledTaskWorker task);
|
void Cancel(IScheduledTaskWorker task);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the tasks.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task">The tasks.</param>
|
||||||
|
/// <param name="options">The options.</param>
|
||||||
|
/// <returns>The executed tasks.</returns>
|
||||||
Task Execute(IScheduledTaskWorker task, TaskOptions options);
|
Task Execute(IScheduledTaskWorker task, TaskOptions options);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the tasks.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
||||||
void Execute<T>()
|
void Execute<T>()
|
||||||
where T : IScheduledTask;
|
where T : IScheduledTask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,33 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class containing event arguments for task completion.
|
||||||
|
/// </summary>
|
||||||
public class TaskCompletionEventArgs : EventArgs
|
public class TaskCompletionEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TaskCompletionEventArgs"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task">Instance of the <see cref="IScheduledTaskWorker"/> interface.</param>
|
||||||
|
/// <param name="result">The task result.</param>
|
||||||
public TaskCompletionEventArgs(IScheduledTaskWorker task, TaskResult result)
|
public TaskCompletionEventArgs(IScheduledTaskWorker task, TaskResult result)
|
||||||
{
|
{
|
||||||
Task = task;
|
Task = task;
|
||||||
Result = result;
|
Result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the task.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The task.</value>
|
||||||
public IScheduledTaskWorker Task { get; }
|
public IScheduledTaskWorker Task { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the result.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The result.</value>
|
||||||
public TaskResult Result { get; }
|
public TaskResult Result { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TaskInfo()
|
public TaskInfo()
|
||||||
{
|
{
|
||||||
Triggers = Array.Empty<TaskTriggerInfo>();
|
Triggers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -50,7 +51,7 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// Gets or sets the triggers.
|
/// Gets or sets the triggers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The triggers.</value>
|
/// <value>The triggers.</value>
|
||||||
public TaskTriggerInfo[] Triggers { get; set; }
|
public IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the description.
|
/// Gets or sets the description.
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class containing options for tasks.
|
||||||
|
/// </summary>
|
||||||
public class TaskOptions
|
public class TaskOptions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the maximum runtime in ticks.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The ticks.</value>
|
||||||
public long? MaxRuntimeTicks { get; set; }
|
public long? MaxRuntimeTicks { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#nullable disable
|
#nullable disable
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Tasks
|
namespace MediaBrowser.Model.Tasks
|
||||||
|
@ -10,9 +8,24 @@ namespace MediaBrowser.Model.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TaskTriggerInfo
|
public class TaskTriggerInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The daily trigger.
|
||||||
|
/// </summary>
|
||||||
public const string TriggerDaily = "DailyTrigger";
|
public const string TriggerDaily = "DailyTrigger";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The weekly trigger.
|
||||||
|
/// </summary>
|
||||||
public const string TriggerWeekly = "WeeklyTrigger";
|
public const string TriggerWeekly = "WeeklyTrigger";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The interval trigger.
|
||||||
|
/// </summary>
|
||||||
public const string TriggerInterval = "IntervalTrigger";
|
public const string TriggerInterval = "IntervalTrigger";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The startup trigger.
|
||||||
|
/// </summary>
|
||||||
public const string TriggerStartup = "StartupTrigger";
|
public const string TriggerStartup = "StartupTrigger";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user