Skip to content

Commit

Permalink
misc: log when automagic cache clearing occurs
Browse files Browse the repository at this point in the history
- Log in the info level when automagic cache clearing occurs. Since not
  everyone have their jellyfin instance set to log Shokofin message at
  debug level (or below).
  • Loading branch information
revam committed Apr 23, 2024
1 parent faa1b97 commit c771322
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Shokofin/Tasks/AutoClearPluginCacheTask.cs
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
using Shokofin.API;
using Shokofin.Resolvers;

Expand Down Expand Up @@ -34,6 +35,8 @@ public class AutoClearPluginCacheTask : IScheduledTask, IConfigurableScheduledTa
/// <inheritdoc />
public bool IsLogged => false;

private readonly ILogger<AutoClearPluginCacheTask> Logger;

private readonly ShokoAPIManager ApiManager;

private readonly ShokoAPIClient ApiClient;
Expand All @@ -43,8 +46,9 @@ public class AutoClearPluginCacheTask : IScheduledTask, IConfigurableScheduledTa
/// <summary>
/// Initializes a new instance of the <see cref="AutoClearPluginCacheTask" /> class.
/// </summary>
public AutoClearPluginCacheTask(ShokoAPIManager apiManager, ShokoAPIClient apiClient, ShokoResolveManager resolveManager)
public AutoClearPluginCacheTask(ILogger<AutoClearPluginCacheTask> logger, ShokoAPIManager apiManager, ShokoAPIClient apiClient, ShokoResolveManager resolveManager)
{
Logger = logger;
ApiManager = apiManager;
ApiClient = apiClient;
ResolveManager = resolveManager;
Expand All @@ -69,6 +73,8 @@ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
/// <returns>Task.</returns>
public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
{
if (ApiClient.IsCacheStalled || ApiManager.IsCacheStalled || ResolveManager.IsCacheStalled)
Logger.LogInformation("Automagically clearing cache…");
if (ApiClient.IsCacheStalled)
ApiClient.Clear();
if (ApiManager.IsCacheStalled)
Expand Down

0 comments on commit c771322

Please sign in to comment.