aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ScheduledTasks
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/ScheduledTasks')
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs12
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs9
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs32
3 files changed, 20 insertions, 33 deletions
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
index df0fdcab8..301c04915 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
@@ -29,7 +29,7 @@ public partial class AudioNormalizationTask : IScheduledTask
private readonly IItemRepository _itemRepository;
private readonly ILibraryManager _libraryManager;
private readonly IMediaEncoder _mediaEncoder;
- private readonly IConfigurationManager _configurationManager;
+ private readonly IApplicationPaths _applicationPaths;
private readonly ILocalizationManager _localization;
private readonly ILogger<AudioNormalizationTask> _logger;
@@ -39,21 +39,21 @@ public partial class AudioNormalizationTask : IScheduledTask
/// <param name="itemRepository">Instance of the <see cref="IItemRepository"/> interface.</param>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
/// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
- /// <param name="configurationManager">Instance of the <see cref="IConfigurationManager"/> interface.</param>
+ /// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
/// <param name="localizationManager">Instance of the <see cref="ILocalizationManager"/> interface.</param>
/// <param name="logger">Instance of the <see cref="ILogger{AudioNormalizationTask}"/> interface.</param>
public AudioNormalizationTask(
IItemRepository itemRepository,
ILibraryManager libraryManager,
IMediaEncoder mediaEncoder,
- IConfigurationManager configurationManager,
+ IApplicationPaths applicationPaths,
ILocalizationManager localizationManager,
ILogger<AudioNormalizationTask> logger)
{
_itemRepository = itemRepository;
_libraryManager = libraryManager;
_mediaEncoder = mediaEncoder;
- _configurationManager = configurationManager;
+ _applicationPaths = applicationPaths;
_localization = localizationManager;
_logger = logger;
}
@@ -107,7 +107,9 @@ public partial class AudioNormalizationTask : IScheduledTask
}
_logger.LogInformation("Calculating LUFS for album: {Album} with id: {Id}", a.Name, a.Id);
- var tempFile = Path.Join(_configurationManager.GetTranscodePath(), a.Id + ".concat");
+ var tempDir = _applicationPaths.TempDirectory;
+ Directory.CreateDirectory(tempDir);
+ var tempFile = Path.Join(tempDir, a.Id + ".concat");
var inputLines = albumTracks.Select(x => string.Format(CultureInfo.InvariantCulture, "file '{0}'", x.Path.Replace("'", @"'\''", StringComparison.Ordinal)));
await File.WriteAllLinesAsync(tempFile, inputLines, cancellationToken).ConfigureAwait(false);
try
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
index 6cb06d31c..254500ccd 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
@@ -62,16 +62,17 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <inheritdoc />
public bool IsLogged => true;
- /// <summary>
- /// Creates the triggers that define when the task will run.
- /// </summary>
- /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
+ /// <inheritdoc />
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new[]
{
new TaskTriggerInfo
{
+ Type = TaskTriggerInfo.TriggerStartup
+ },
+ new TaskTriggerInfo
+ {
Type = TaskTriggerInfo.TriggerInterval,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
index d65ac2e5e..9425b47d0 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Triggers/IntervalTrigger.cs
@@ -27,45 +27,31 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
TaskOptions = taskOptions;
}
- /// <summary>
- /// Occurs when [triggered].
- /// </summary>
+ /// <inheritdoc />
public event EventHandler<EventArgs>? Triggered;
- /// <summary>
- /// Gets the options of this task.
- /// </summary>
+ /// <inheritdoc />
public TaskOptions TaskOptions { get; }
- /// <summary>
- /// 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>
+ /// <inheritdoc />
public void Start(TaskResult? lastResult, ILogger logger, string taskName, bool isApplicationStartup)
{
DisposeTimer();
+ DateTime now = DateTime.UtcNow;
DateTime triggerDate;
if (lastResult is null)
{
// Task has never been completed before
- triggerDate = DateTime.UtcNow.AddHours(1);
+ triggerDate = now.AddHours(1);
}
else
{
- triggerDate = new[] { lastResult.EndTimeUtc, _lastStartDate }.Max().Add(_interval);
- }
-
- if (DateTime.UtcNow > triggerDate)
- {
- triggerDate = DateTime.UtcNow.AddMinutes(1);
+ triggerDate = new[] { lastResult.EndTimeUtc, _lastStartDate, now.AddMinutes(1) }.Max().Add(_interval);
}
- var dueTime = triggerDate - DateTime.UtcNow;
+ var dueTime = triggerDate - now;
var maxDueTime = TimeSpan.FromDays(7);
if (dueTime > maxDueTime)
@@ -76,9 +62,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
_timer = new Timer(_ => OnTriggered(), null, dueTime, TimeSpan.FromMilliseconds(-1));
}
- /// <summary>
- /// Stops waiting for the trigger action.
- /// </summary>
+ /// <inheritdoc />
public void Stop()
{
DisposeTimer();