fix: slow start of jellyfin

This commit is contained in:
2026-04-07 08:38:18 +02:00
parent 0bafe691a0
commit 85fd002f4e

View File

@@ -50,11 +50,7 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
{
_logger.LogInformation("SmartNotify background service starting");
// Pre-populate DB with all existing library items so they're recognized as "known".
// This prevents mass notifications on first run or after DB reset.
SeedExistingLibraryItems();
// Subscribe to library events
// Subscribe to library events (before seeding so we don't miss items added during seed).
_libraryManager.ItemAdded += OnItemAdded;
_libraryManager.ItemRemoved += OnItemRemoved;
@@ -64,6 +60,10 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
_processTimer.AutoReset = true;
_processTimer.Start();
// Pre-populate DB with existing library items in the background
// so we don't block Jellyfin startup.
_ = Task.Run(() => SeedExistingLibraryItems(), cancellationToken);
_logger.LogInformation("SmartNotify is now monitoring library changes");
return Task.CompletedTask;