repo creation with initial code after cloning public repo

This commit is contained in:
2026-02-19 07:36:25 -05:00
commit 460884fea3
2860 changed files with 650825 additions and 0 deletions
@@ -0,0 +1,26 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface for configurable scheduled tasks.
/// </summary>
public interface IConfigurableScheduledTask
{
/// <summary>
/// Gets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
bool IsHidden { get; }
/// <summary>
/// Gets a value indicating whether this instance is enabled.
/// </summary>
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
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; }
}
}
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface IScheduledTaskWorker.
/// </summary>
public interface IScheduledTask
{
/// <summary>
/// Gets the name of the task.
/// </summary>
/// <value>The name.</value>
string Name { get; }
/// <summary>
/// Gets the key of the task.
/// </summary>
string Key { get; }
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
string Description { get; }
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
string Category { get; }
/// <summary>
/// Executes the task.
/// </summary>
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken);
/// <summary>
/// Gets the default triggers that define when the task will run.
/// </summary>
/// <returns>The default triggers that define when the task will run.</returns>
IEnumerable<TaskTriggerInfo> GetDefaultTriggers();
}
}
@@ -0,0 +1,77 @@
#nullable disable
using System;
using System.Collections.Generic;
using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface IScheduledTaskWorker.
/// </summary>
public interface IScheduledTaskWorker : IDisposable
{
/// <summary>
/// Occurs when [task progress].
/// </summary>
event EventHandler<GenericEventArgs<double>> TaskProgress;
/// <summary>
/// Gets the scheduled task.
/// </summary>
/// <value>The scheduled task.</value>
IScheduledTask ScheduledTask { get; }
/// <summary>
/// Gets the last execution result.
/// </summary>
/// <value>The last execution result.</value>
TaskResult LastExecutionResult { get; }
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
string Name { get; }
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
string Description { get; }
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
string Category { get; }
/// <summary>
/// Gets the state.
/// </summary>
/// <value>The state.</value>
TaskState State { get; }
/// <summary>
/// Gets the current progress.
/// </summary>
/// <value>The current progress.</value>
double? CurrentProgress { get; }
/// <summary>
/// Gets or sets the triggers that define when the task will run.
/// </summary>
/// <value>The triggers.</value>
IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
/// <summary>
/// Gets the unique id.
/// </summary>
/// <value>The unique id.</value>
string Id { get; }
/// <summary>
/// Reloads the trigger events.
/// </summary>
void ReloadTriggerEvents();
}
}
+107
View File
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface for the TaskManager class.
/// </summary>
public interface ITaskManager : IDisposable
{
/// <summary>
/// Event handler for task execution.
/// </summary>
event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
/// <summary>
/// Event handler for task completion.
/// </summary>
event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
/// <summary>
/// Gets the list of Scheduled Tasks.
/// </summary>
/// <value>The scheduled tasks.</value>
IReadOnlyList<IScheduledTaskWorker> ScheduledTasks { get; }
/// <summary>
/// Cancels if running and queue.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
/// <param name="options">Task options.</param>
void CancelIfRunningAndQueue<T>(TaskOptions options)
where T : IScheduledTask;
/// <summary>
/// Cancels if running and queue.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
void CancelIfRunningAndQueue<T>()
where T : IScheduledTask;
/// <summary>
/// Cancels if running.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
void CancelIfRunning<T>()
where T : IScheduledTask;
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
/// <param name="options">Task options.</param>
void QueueScheduledTask<T>(TaskOptions options)
where T : IScheduledTask;
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
void QueueScheduledTask<T>()
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>()
where T : IScheduledTask;
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <param name="task">The <see cref="IScheduledTask" /> to queue.</param>
/// <param name="options">The <see cref="TaskOptions" /> to use.</param>
void QueueScheduledTask(IScheduledTask task, TaskOptions options);
/// <summary>
/// Adds the tasks.
/// </summary>
/// <param name="tasks">The tasks.</param>
void AddTasks(IEnumerable<IScheduledTask> tasks);
/// <summary>
/// Adds the tasks.
/// </summary>
/// <param name="task">The tasks.</param>
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);
/// <summary>
/// Executes the tasks.
/// </summary>
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
void Execute<T>()
where T : IScheduledTask;
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Interface ITaskTrigger.
/// </summary>
public interface ITaskTrigger
{
/// <summary>
/// Fires when the trigger condition is satisfied and the task should run.
/// </summary>
event EventHandler<EventArgs>? Triggered;
/// <summary>
/// Gets the options of this task.
/// </summary>
TaskOptions TaskOptions { get; }
/// <summary>
/// Stars waiting for the trigger action.
/// </summary>
/// <param name="lastResult">Result of the last run triggered task.</param>
/// <param name="logger">The <see cref="ILogger"/>.</param>
/// <param name="taskName">The name of the task.</param>
/// <param name="isApplicationStartup">Whether or not this is fired during startup.</param>
void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup);
/// <summary>
/// Stops waiting for the trigger action.
/// </summary>
void Stop();
}
}
@@ -0,0 +1,41 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class ScheduledTaskHelpers.
/// </summary>
public static class ScheduledTaskHelpers
{
/// <summary>
/// Gets the task info.
/// </summary>
/// <param name="task">The task.</param>
/// <returns>TaskInfo.</returns>
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
{
var isHidden = false;
if (task.ScheduledTask is IConfigurableScheduledTask configurableTask)
{
isHidden = configurableTask.IsHidden;
}
string key = task.ScheduledTask.Key;
return new TaskInfo
{
Name = task.Name,
CurrentProgressPercentage = task.CurrentProgress,
State = task.State,
Id = task.Id,
LastExecutionResult = task.LastExecutionResult,
Triggers = task.Triggers,
Description = task.Description,
Category = task.Category,
IsHidden = isHidden,
Key = key
};
}
}
}
@@ -0,0 +1,33 @@
using System;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class containing event arguments for task completion.
/// </summary>
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)
{
Task = task;
Result = result;
}
/// <summary>
/// Gets the task.
/// </summary>
/// <value>The task.</value>
public IScheduledTaskWorker Task { get; }
/// <summary>
/// Gets the result.
/// </summary>
/// <value>The result.</value>
public TaskResult Result { get; }
}
}
@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Enum TaskCompletionStatus.
/// </summary>
public enum TaskCompletionStatus
{
/// <summary>
/// The completed.
/// </summary>
Completed,
/// <summary>
/// The failed.
/// </summary>
Failed,
/// <summary>
/// Manually cancelled by the user.
/// </summary>
Cancelled,
/// <summary>
/// Aborted due to a system failure or shutdown.
/// </summary>
Aborted
}
}
+80
View File
@@ -0,0 +1,80 @@
#nullable disable
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class TaskInfo.
/// </summary>
public class TaskInfo
{
/// <summary>
/// Initializes a new instance of the <see cref="TaskInfo"/> class.
/// </summary>
public TaskInfo()
{
Triggers = [];
}
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the state of the task.
/// </summary>
/// <value>The state of the task.</value>
public TaskState State { get; set; }
/// <summary>
/// Gets or sets the progress.
/// </summary>
/// <value>The progress.</value>
public double? CurrentProgressPercentage { get; set; }
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the last execution result.
/// </summary>
/// <value>The last execution result.</value>
public TaskResult LastExecutionResult { get; set; }
/// <summary>
/// Gets or sets the triggers.
/// </summary>
/// <value>The triggers.</value>
public IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
public string Description { get; set; }
/// <summary>
/// Gets or sets the category.
/// </summary>
/// <value>The category.</value>
public string Category { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
public bool IsHidden { get; set; }
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>The key.</value>
public string Key { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class containing options for tasks.
/// </summary>
public class TaskOptions
{
/// <summary>
/// Gets or sets the maximum runtime in ticks.
/// </summary>
/// <value>The ticks.</value>
public long? MaxRuntimeTicks { get; set; }
}
}
+59
View File
@@ -0,0 +1,59 @@
#nullable disable
using System;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class TaskExecutionInfo.
/// </summary>
public class TaskResult
{
/// <summary>
/// Gets or sets the start time UTC.
/// </summary>
/// <value>The start time UTC.</value>
public DateTime StartTimeUtc { get; set; }
/// <summary>
/// Gets or sets the end time UTC.
/// </summary>
/// <value>The end time UTC.</value>
public DateTime EndTimeUtc { get; set; }
/// <summary>
/// Gets or sets the status.
/// </summary>
/// <value>The status.</value>
public TaskCompletionStatus Status { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>The key.</value>
public string Key { get; set; }
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the error message.
/// </summary>
/// <value>The error message.</value>
public string ErrorMessage { get; set; }
/// <summary>
/// Gets or sets the long error message.
/// </summary>
/// <value>The long error message.</value>
public string LongErrorMessage { get; set; }
}
}
+23
View File
@@ -0,0 +1,23 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Enum TaskState.
/// </summary>
public enum TaskState
{
/// <summary>
/// The idle.
/// </summary>
Idle,
/// <summary>
/// The cancelling.
/// </summary>
Cancelling,
/// <summary>
/// The running.
/// </summary>
Running
}
}
@@ -0,0 +1,41 @@
#nullable disable
using System;
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Class TaskTriggerInfo.
/// </summary>
public class TaskTriggerInfo
{
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public TaskTriggerInfoType Type { get; set; }
/// <summary>
/// Gets or sets the time of day.
/// </summary>
/// <value>The time of day.</value>
public long? TimeOfDayTicks { get; set; }
/// <summary>
/// Gets or sets the interval.
/// </summary>
/// <value>The interval.</value>
public long? IntervalTicks { get; set; }
/// <summary>
/// Gets or sets the day of week.
/// </summary>
/// <value>The day of week.</value>
public DayOfWeek? DayOfWeek { get; set; }
/// <summary>
/// Gets or sets the maximum runtime ticks.
/// </summary>
/// <value>The maximum runtime ticks.</value>
public long? MaxRuntimeTicks { get; set; }
}
}
@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Enum TaskTriggerInfoType.
/// </summary>
public enum TaskTriggerInfoType
{
/// <summary>
/// The daily trigger.
/// </summary>
DailyTrigger,
/// <summary>
/// The weekly trigger.
/// </summary>
WeeklyTrigger,
/// <summary>
/// The interval trigger.
/// </summary>
IntervalTrigger,
/// <summary>
/// The startup trigger.
/// </summary>
StartupTrigger
}
}