mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 01:34:45 +03:00
Cleanup tasks
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -24,51 +23,15 @@ 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>
|
||||
/// <value>The application paths.</value>
|
||||
private readonly IApplicationPaths _applicationPaths;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the task manager.
|
||||
/// </summary>
|
||||
/// <value>The task manager.</value>
|
||||
private readonly ITaskManager _taskManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _last execution result sync lock.
|
||||
/// </summary>
|
||||
private readonly object _lastExecutionResultSyncLock = new object();
|
||||
|
||||
private bool _readFromFile = false;
|
||||
|
||||
/// <summary>
|
||||
/// The _last execution result.
|
||||
/// </summary>
|
||||
private readonly object _lastExecutionResultSyncLock = new();
|
||||
private bool _readFromFile;
|
||||
private TaskResult _lastExecutionResult;
|
||||
|
||||
private Task _currentTask;
|
||||
|
||||
/// <summary>
|
||||
/// The _triggers.
|
||||
/// </summary>
|
||||
private Tuple<TaskTriggerInfo, ITaskTrigger>[] _triggers;
|
||||
|
||||
/// <summary>
|
||||
/// The _id.
|
||||
/// </summary>
|
||||
private string _id;
|
||||
|
||||
/// <summary>
|
||||
@@ -104,18 +67,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
InitTriggerEvents();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<GenericEventArgs<double>> TaskProgress;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scheduled task.
|
||||
/// </summary>
|
||||
/// <value>The scheduled task.</value>
|
||||
/// <inheritdoc />
|
||||
public IScheduledTask ScheduledTask { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last execution result.
|
||||
/// </summary>
|
||||
/// <value>The last execution result.</value>
|
||||
/// <inheritdoc />
|
||||
public TaskResult LastExecutionResult
|
||||
{
|
||||
get
|
||||
@@ -169,22 +127,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
/// <inheritdoc />
|
||||
public string Name => ScheduledTask.Name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
/// <inheritdoc />
|
||||
public string Description => ScheduledTask.Description;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category.
|
||||
/// </summary>
|
||||
/// <value>The category.</value>
|
||||
/// <inheritdoc />
|
||||
public string Category => ScheduledTask.Category;
|
||||
|
||||
/// <summary>
|
||||
@@ -199,10 +148,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
/// <value>The current execution start time.</value>
|
||||
private DateTime CurrentExecutionStartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state.
|
||||
/// </summary>
|
||||
/// <value>The state.</value>
|
||||
/// <inheritdoc />
|
||||
public TaskState State
|
||||
{
|
||||
get
|
||||
@@ -218,10 +164,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current progress.
|
||||
/// </summary>
|
||||
/// <value>The current progress.</value>
|
||||
/// <inheritdoc />
|
||||
public double? CurrentProgress { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -247,12 +190,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the triggers that define when the task will run.
|
||||
/// </summary>
|
||||
/// <value>The triggers.</value>
|
||||
/// <exception cref="ArgumentNullException"><c>value</c> is <c>null</c>.</exception>
|
||||
public TaskTriggerInfo[] Triggers
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<TaskTriggerInfo> Triggers
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -272,10 +211,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique id.
|
||||
/// </summary>
|
||||
/// <value>The unique id.</value>
|
||||
/// <inheritdoc />
|
||||
public string Id
|
||||
{
|
||||
get
|
||||
@@ -290,6 +226,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
ReloadTriggerEvents(true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ReloadTriggerEvents()
|
||||
{
|
||||
ReloadTriggerEvents(false);
|
||||
@@ -529,14 +466,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new TaskTriggerInfo[]
|
||||
{
|
||||
new TaskTriggerInfo
|
||||
return
|
||||
[
|
||||
new()
|
||||
{
|
||||
IntervalTicks = TimeSpan.FromDays(1).Ticks,
|
||||
Type = TaskTriggerInfo.TriggerInterval
|
||||
}
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,9 +526,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
((TaskManager)_taskManager).OnTaskCompleted(this, result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
Reference in New Issue
Block a user