Files
jellyfin-plugin-recently-ad…/Jellyfin.Plugin.RecentlyAddedGuard/Tasks/SyncLedgerTask.cs
T
Jonas MenzelandClaude Opus 5.5 d431486095
build / build (push) Successful in 1m10s
release / release (push) Failing after 1m36s
feat: Recently Added Guard plugin for Jellyfin 12.2
Keeps Radarr/Sonarr quality upgrades out of "Recently Added" by keeping
a ledger of the first date added per logical medium (movie or episode,
identified by provider ids and the series) and restoring it on upgrades.

- core logic without Jellyfin types (Reconciler, MediaKeys, GuardProcessor)
- thread-safe ledger with atomic, debounced persistence
- event processing via channel and background worker, seed on first start
- scheduled task "Ledger synchronisieren", status API, configuration page
- xUnit tests and a Jellyfin 12.2 integration test
- Gitea workflows: build/test, release with jprm and manifest branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 23:10:02 +02:00

60 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Plugin.RecentlyAddedGuard.Services;
using MediaBrowser.Model.Tasks;
namespace Jellyfin.Plugin.RecentlyAddedGuard.Tasks;
/// <summary>
/// Scheduled task "Ledger synchronisieren": registers unknown items, updates live items and prunes the ledger.
/// It never changes library items.
/// </summary>
public class SyncLedgerTask : IScheduledTask
{
/// <summary>
/// The task key.
/// </summary>
public const string TaskKey = "RecentlyAddedGuardSyncLedger";
private readonly LedgerSynchronizer _synchronizer;
/// <summary>
/// Initializes a new instance of the <see cref="SyncLedgerTask"/> class.
/// </summary>
/// <param name="synchronizer">The synchronizer.</param>
public SyncLedgerTask(LedgerSynchronizer synchronizer)
{
_synchronizer = synchronizer;
}
/// <inheritdoc />
public string Name => "Ledger synchronisieren";
/// <inheritdoc />
public string Key => TaskKey;
/// <inheritdoc />
public string Description
=> "Gleicht das Ledger von Recently Added Guard mit der Bibliothek ab: registriert unbekannte Filme und Episoden, "
+ "trägt gelöschte Items aus und bereinigt abgelaufene Einträge. Ändert keine Items.";
/// <inheritdoc />
public string Category => "Recently Added Guard";
/// <inheritdoc />
public Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
=> _synchronizer.RunAsync(progress, cancellationToken);
/// <inheritdoc />
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
yield return new TaskTriggerInfo
{
Type = TaskTriggerInfoType.DailyTrigger,
TimeOfDayTicks = TimeSpan.FromHours(3).Ticks
};
}
}