diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b99bc4f974..549ea9be2a 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -9,6 +9,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.ScheduledTasks; using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.ScheduledTasks; @@ -121,6 +122,8 @@ namespace MediaBrowser.Server.Implementations.Library ConfigurationManager = configurationManager; ConfigurationManager.ConfigurationUpdated += kernel_ConfigurationUpdated; + + RecordConfigurationValues(configurationManager.Configuration); } /// @@ -174,6 +177,15 @@ namespace MediaBrowser.Server.Implementations.Library } } + private bool _internetProvidersEnabled; + private bool _peopleImageFetchingEnabled; + + private void RecordConfigurationValues(ServerConfiguration configuration) + { + _internetProvidersEnabled = configuration.EnableInternetProviders; + _peopleImageFetchingEnabled = configuration.InternetProviderExcludeTypes == null || !configuration.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase); + } + /// /// Handles the ConfigurationUpdated event of the kernel control. /// @@ -181,23 +193,30 @@ namespace MediaBrowser.Server.Implementations.Library /// The instance containing the event data. void kernel_ConfigurationUpdated(object sender, EventArgs e) { - //// Figure out whether or not we should refresh people after the update is finished - //var refreshPeopleAfterUpdate = !oldConfiguration.EnableInternetProviders && config.EnableInternetProviders; + var config = ConfigurationManager.Configuration; - //// This is true if internet providers has just been turned on, or if People have just been removed from InternetProviderExcludeTypes - //if (!refreshPeopleAfterUpdate) - //{ - // var oldConfigurationFetchesPeopleImages = oldConfiguration.InternetProviderExcludeTypes == null || !oldConfiguration.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase); - // var newConfigurationFetchesPeopleImages = config.InternetProviderExcludeTypes == null || !config.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase); + // Figure out whether or not we should refresh people after the update is finished + var refreshPeopleAfterUpdate = !_internetProvidersEnabled && config.EnableInternetProviders; - // refreshPeopleAfterUpdate = newConfigurationFetchesPeopleImages && !oldConfigurationFetchesPeopleImages; - //} + // This is true if internet providers has just been turned on, or if People have just been removed from InternetProviderExcludeTypes + if (!refreshPeopleAfterUpdate) + { + var newConfigurationFetchesPeopleImages = config.InternetProviderExcludeTypes == null || !config.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase); + + refreshPeopleAfterUpdate = newConfigurationFetchesPeopleImages && !_peopleImageFetchingEnabled; + } + + RecordConfigurationValues(config); Task.Run(() => { // Any number of configuration settings could change the way the library is refreshed, so do that now _taskManager.CancelIfRunningAndQueue(); - _taskManager.CancelIfRunningAndQueue(); + + if (refreshPeopleAfterUpdate) + { + _taskManager.CancelIfRunningAndQueue(); + } }); }