When a scan is already running, append it
This commit is contained in:
parent
b1e94bd24c
commit
3096f3fe6a
@ -26,6 +26,7 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
private bool _analyzeAgain;
|
private bool _analyzeAgain;
|
||||||
private static CancellationTokenSource? _cancellationTokenSource;
|
private static CancellationTokenSource? _cancellationTokenSource;
|
||||||
private static ManualResetEventSlim _autoTaskCompletEvent = new ManualResetEventSlim(false);
|
private static ManualResetEventSlim _autoTaskCompletEvent = new ManualResetEventSlim(false);
|
||||||
|
private QueueManager _queueManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Entrypoint"/> class.
|
/// Initializes a new instance of the <see cref="Entrypoint"/> class.
|
||||||
@ -56,6 +57,10 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
null,
|
null,
|
||||||
Timeout.InfiniteTimeSpan,
|
Timeout.InfiniteTimeSpan,
|
||||||
Timeout.InfiniteTimeSpan);
|
Timeout.InfiniteTimeSpan);
|
||||||
|
|
||||||
|
_queueManager = new QueueManager(
|
||||||
|
_loggerFactory.CreateLogger<QueueManager>(),
|
||||||
|
_libraryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -92,8 +97,7 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
{
|
{
|
||||||
// Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
|
// Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
|
||||||
_logger.LogInformation("Running startup enqueue");
|
_logger.LogInformation("Running startup enqueue");
|
||||||
var queueManager = new QueueManager(_loggerFactory.CreateLogger<QueueManager>(), _libraryManager);
|
_queueManager.GetMediaItems();
|
||||||
queueManager.GetMediaItems();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -121,7 +125,7 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't do anything if it's not a supported media type
|
// Don't do anything if it's not a supported media type
|
||||||
if (itemChangeEventArgs.Item is not Episode)
|
if (itemChangeEventArgs.Item is not Episode episode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,10 +135,16 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Plugin.Instance!.AnalyzerTaskIsRunning)
|
||||||
|
{
|
||||||
|
_queueManager.QueueEpisode(episode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
|
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
|
||||||
|
|
||||||
StartTimer();
|
StartTimer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Library item was modified.
|
/// Library item was modified.
|
||||||
@ -150,7 +160,7 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't do anything if it's not a supported media type
|
// Don't do anything if it's not a supported media type
|
||||||
if (itemChangeEventArgs.Item is not Episode)
|
if (itemChangeEventArgs.Item is not Episode episode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,10 +170,16 @@ public class Entrypoint : IServerEntryPoint
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Plugin.Instance!.AnalyzerTaskIsRunning)
|
||||||
|
{
|
||||||
|
_queueManager.QueueEpisode(episode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
|
Plugin.Instance!.Configuration.PathRestrictions.Add(itemChangeEventArgs.Item.ContainingFolderPath);
|
||||||
|
|
||||||
StartTimer();
|
StartTimer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TaskManager task ended.
|
/// TaskManager task ended.
|
||||||
|
@ -171,7 +171,11 @@ public class QueueManager
|
|||||||
_logger.LogDebug("Queued {Count} episodes", items.Count);
|
_logger.LogDebug("Queued {Count} episodes", items.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void QueueEpisode(Episode episode)
|
/// <summary>
|
||||||
|
/// Adds a single episode to the current queue for analyzing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="episode">The episode to analyze.</param>
|
||||||
|
public void QueueEpisode(Episode episode)
|
||||||
{
|
{
|
||||||
if (Plugin.Instance is null)
|
if (Plugin.Instance is null)
|
||||||
{
|
{
|
||||||
|
@ -74,11 +74,6 @@ public class DetectCreditsTask : IScheduledTask
|
|||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
else if (Plugin.Instance!.AnalyzerTaskIsRunning && Entrypoint.AutomaticTaskState == TaskState.Running)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Automatic Task is {0} and will be canceled.", Entrypoint.AutomaticTaskState);
|
|
||||||
Entrypoint.CancelAutomaticTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Scheduled Task is starting");
|
_logger.LogInformation("Scheduled Task is starting");
|
||||||
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
||||||
|
@ -73,11 +73,6 @@ public class DetectIntrosCreditsTask : IScheduledTask
|
|||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
else if (Plugin.Instance!.AnalyzerTaskIsRunning && Entrypoint.AutomaticTaskState == TaskState.Running)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Automatic Task is {0} and will be canceled.", Entrypoint.AutomaticTaskState);
|
|
||||||
Entrypoint.CancelAutomaticTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Scheduled Task is starting");
|
_logger.LogInformation("Scheduled Task is starting");
|
||||||
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
||||||
|
@ -73,11 +73,6 @@ public class DetectIntrosTask : IScheduledTask
|
|||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
else if (Plugin.Instance!.AnalyzerTaskIsRunning && Entrypoint.AutomaticTaskState == TaskState.Running)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Automatic Task is {0} and will be canceled.", Entrypoint.AutomaticTaskState);
|
|
||||||
Entrypoint.CancelAutomaticTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Scheduled Task is starting");
|
_logger.LogInformation("Scheduled Task is starting");
|
||||||
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
Plugin.Instance!.AnalyzerTaskIsRunning = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user