mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	Merge pull request #9894 from fhriley/fix_hardcoded_timer
This commit is contained in:
		
						commit
						143f2abd38
					
				@ -12,6 +12,7 @@ using System.Threading.Tasks;
 | 
				
			|||||||
using Jellyfin.Data.Entities;
 | 
					using Jellyfin.Data.Entities;
 | 
				
			||||||
using Jellyfin.Data.Events;
 | 
					using Jellyfin.Data.Events;
 | 
				
			||||||
using MediaBrowser.Controller.Channels;
 | 
					using MediaBrowser.Controller.Channels;
 | 
				
			||||||
 | 
					using MediaBrowser.Controller.Configuration;
 | 
				
			||||||
using MediaBrowser.Controller.Entities;
 | 
					using MediaBrowser.Controller.Entities;
 | 
				
			||||||
using MediaBrowser.Controller.Entities.Audio;
 | 
					using MediaBrowser.Controller.Entities.Audio;
 | 
				
			||||||
using MediaBrowser.Controller.Library;
 | 
					using MediaBrowser.Controller.Library;
 | 
				
			||||||
@ -26,12 +27,8 @@ namespace Emby.Server.Implementations.EntryPoints
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class LibraryChangedNotifier : IServerEntryPoint
 | 
					    public class LibraryChangedNotifier : IServerEntryPoint
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// The library update duration.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        private const int LibraryUpdateDuration = 30000;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILibraryManager _libraryManager;
 | 
					        private readonly ILibraryManager _libraryManager;
 | 
				
			||||||
 | 
					        private readonly IServerConfigurationManager _configurationManager;
 | 
				
			||||||
        private readonly IProviderManager _providerManager;
 | 
					        private readonly IProviderManager _providerManager;
 | 
				
			||||||
        private readonly ISessionManager _sessionManager;
 | 
					        private readonly ISessionManager _sessionManager;
 | 
				
			||||||
        private readonly IUserManager _userManager;
 | 
					        private readonly IUserManager _userManager;
 | 
				
			||||||
@ -51,12 +48,14 @@ namespace Emby.Server.Implementations.EntryPoints
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public LibraryChangedNotifier(
 | 
					        public LibraryChangedNotifier(
 | 
				
			||||||
            ILibraryManager libraryManager,
 | 
					            ILibraryManager libraryManager,
 | 
				
			||||||
 | 
					            IServerConfigurationManager configurationManager,
 | 
				
			||||||
            ISessionManager sessionManager,
 | 
					            ISessionManager sessionManager,
 | 
				
			||||||
            IUserManager userManager,
 | 
					            IUserManager userManager,
 | 
				
			||||||
            ILogger<LibraryChangedNotifier> logger,
 | 
					            ILogger<LibraryChangedNotifier> logger,
 | 
				
			||||||
            IProviderManager providerManager)
 | 
					            IProviderManager providerManager)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _libraryManager = libraryManager;
 | 
					            _libraryManager = libraryManager;
 | 
				
			||||||
 | 
					            _configurationManager = configurationManager;
 | 
				
			||||||
            _sessionManager = sessionManager;
 | 
					            _sessionManager = sessionManager;
 | 
				
			||||||
            _userManager = userManager;
 | 
					            _userManager = userManager;
 | 
				
			||||||
            _logger = logger;
 | 
					            _logger = logger;
 | 
				
			||||||
@ -196,12 +195,12 @@ namespace Emby.Server.Implementations.EntryPoints
 | 
				
			|||||||
                    LibraryUpdateTimer = new Timer(
 | 
					                    LibraryUpdateTimer = new Timer(
 | 
				
			||||||
                        LibraryUpdateTimerCallback,
 | 
					                        LibraryUpdateTimerCallback,
 | 
				
			||||||
                        null,
 | 
					                        null,
 | 
				
			||||||
                        LibraryUpdateDuration,
 | 
					                        TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration),
 | 
				
			||||||
                        Timeout.Infinite);
 | 
					                        Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
 | 
					                    LibraryUpdateTimer.Change(TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration), Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (e.Item.GetParent() is Folder parent)
 | 
					                if (e.Item.GetParent() is Folder parent)
 | 
				
			||||||
@ -229,11 +228,11 @@ namespace Emby.Server.Implementations.EntryPoints
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                if (LibraryUpdateTimer is null)
 | 
					                if (LibraryUpdateTimer is null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite);
 | 
					                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration), Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
 | 
					                    LibraryUpdateTimer.Change(TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration), Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                _itemsUpdated.Add(e.Item);
 | 
					                _itemsUpdated.Add(e.Item);
 | 
				
			||||||
@ -256,11 +255,11 @@ namespace Emby.Server.Implementations.EntryPoints
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                if (LibraryUpdateTimer is null)
 | 
					                if (LibraryUpdateTimer is null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, Timeout.Infinite);
 | 
					                    LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration), Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
 | 
					                    LibraryUpdateTimer.Change(TimeSpan.FromSeconds(_configurationManager.Configuration.LibraryUpdateDuration), Timeout.InfiniteTimeSpan);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (e.Parent is Folder parent)
 | 
					                if (e.Parent is Folder parent)
 | 
				
			||||||
 | 
				
			|||||||
@ -165,6 +165,12 @@ namespace MediaBrowser.Model.Configuration
 | 
				
			|||||||
        /// <value>The file watcher delay.</value>
 | 
					        /// <value>The file watcher delay.</value>
 | 
				
			||||||
        public int LibraryMonitorDelay { get; set; } = 60;
 | 
					        public int LibraryMonitorDelay { get; set; } = 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets or sets the duration in seconds that we will wait after a library updated event before executing the library changed notification.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <value>The library update duration.</value>
 | 
				
			||||||
 | 
					        public int LibraryUpdateDuration { get; set; } = 30;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Gets or sets the image saving convention.
 | 
					        /// Gets or sets the image saving convention.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user