Browse Source

Fix a couple of TODOs

Bond-009 5 years ago
parent
commit
49330e3082

+ 12 - 24
Emby.Dlna/Eventing/EventManager.cs

@@ -29,25 +29,15 @@ namespace Emby.Dlna.Eventing
         {
         {
             var subscription = GetSubscription(subscriptionId, false);
             var subscription = GetSubscription(subscriptionId, false);
 
 
-            int timeoutSeconds;
+            subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;
+            int timeoutSeconds = subscription.TimeoutSeconds;
+            subscription.SubscriptionTime = DateTime.UtcNow;
 
 
-            // Remove logging for now because some devices are sending this very frequently
-            // TODO re-enable with dlna debug logging setting
-            //_logger.LogDebug("Renewing event subscription for {0} with timeout of {1} to {2}",
-            //    subscription.NotificationType,
-            //    timeout,
-            //    subscription.CallbackUrl);
-
-            if (subscription != null)
-            {
-                subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;
-                timeoutSeconds = subscription.TimeoutSeconds;
-                subscription.SubscriptionTime = DateTime.UtcNow;
-            }
-            else
-            {
-                timeoutSeconds = 300;
-            }
+            _logger.LogDebug(
+                "Renewing event subscription for {0} with timeout of {1} to {2}",
+                subscription.NotificationType,
+                timeoutSeconds,
+                subscription.CallbackUrl);
 
 
             return GetEventSubscriptionResponse(subscriptionId, requestedTimeoutString, timeoutSeconds);
             return GetEventSubscriptionResponse(subscriptionId, requestedTimeoutString, timeoutSeconds);
         }
         }
@@ -57,12 +47,10 @@ namespace Emby.Dlna.Eventing
             var timeout = ParseTimeout(requestedTimeoutString) ?? 300;
             var timeout = ParseTimeout(requestedTimeoutString) ?? 300;
             var id = "uuid:" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
             var id = "uuid:" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
 
 
-            // Remove logging for now because some devices are sending this very frequently
-            // TODO re-enable with dlna debug logging setting
-            //_logger.LogDebug("Creating event subscription for {0} with timeout of {1} to {2}",
-            //    notificationType,
-            //    timeout,
-            //    callbackUrl);
+            _logger.LogDebug("Creating event subscription for {0} with timeout of {1} to {2}",
+                notificationType,
+                timeout,
+                callbackUrl);
 
 
             _subscriptions.TryAdd(id, new EventSubscription
             _subscriptions.TryAdd(id, new EventSubscription
             {
             {

+ 1 - 2
Emby.Server.Implementations/ApplicationHost.cs

@@ -764,9 +764,8 @@ namespace Emby.Server.Implementations
             LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
             LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
             serviceCollection.AddSingleton(LibraryManager);
             serviceCollection.AddSingleton(LibraryManager);
 
 
-            // TODO wtaylor: investigate use of second music manager
             var musicManager = new MusicManager(LibraryManager);
             var musicManager = new MusicManager(LibraryManager);
-            serviceCollection.AddSingleton<IMusicManager>(new MusicManager(LibraryManager));
+            serviceCollection.AddSingleton<IMusicManager>(musicManager);
 
 
             LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager);
             LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager);
             serviceCollection.AddSingleton(LibraryMonitor);
             serviceCollection.AddSingleton(LibraryMonitor);

+ 10 - 38
Emby.Server.Implementations/Collections/CollectionManager.cs

@@ -31,11 +31,7 @@ namespace Emby.Server.Implementations.Collections
         private readonly ILogger _logger;
         private readonly ILogger _logger;
         private readonly IProviderManager _providerManager;
         private readonly IProviderManager _providerManager;
         private readonly ILocalizationManager _localizationManager;
         private readonly ILocalizationManager _localizationManager;
-        private IApplicationPaths _appPaths;
-
-        public event EventHandler<CollectionCreatedEventArgs> CollectionCreated;
-        public event EventHandler<CollectionModifiedEventArgs> ItemsAddedToCollection;
-        public event EventHandler<CollectionModifiedEventArgs> ItemsRemovedFromCollection;
+        private readonly IApplicationPaths _appPaths;
 
 
         public CollectionManager(
         public CollectionManager(
             ILibraryManager libraryManager,
             ILibraryManager libraryManager,
@@ -55,6 +51,10 @@ namespace Emby.Server.Implementations.Collections
             _appPaths = appPaths;
             _appPaths = appPaths;
         }
         }
 
 
+        public event EventHandler<CollectionCreatedEventArgs> CollectionCreated;
+        public event EventHandler<CollectionModifiedEventArgs> ItemsAddedToCollection;
+        public event EventHandler<CollectionModifiedEventArgs> ItemsRemovedFromCollection;
+
         private IEnumerable<Folder> FindFolders(string path)
         private IEnumerable<Folder> FindFolders(string path)
         {
         {
             return _libraryManager
             return _libraryManager
@@ -341,11 +341,11 @@ namespace Emby.Server.Implementations.Collections
         }
         }
     }
     }
 
 
-    public class CollectionManagerEntryPoint : IServerEntryPoint
+    public sealed class CollectionManagerEntryPoint : IServerEntryPoint
     {
     {
         private readonly CollectionManager _collectionManager;
         private readonly CollectionManager _collectionManager;
         private readonly IServerConfigurationManager _config;
         private readonly IServerConfigurationManager _config;
-        private ILogger _logger;
+        private readonly ILogger _logger;
 
 
         public CollectionManagerEntryPoint(ICollectionManager collectionManager, IServerConfigurationManager config, ILogger logger)
         public CollectionManagerEntryPoint(ICollectionManager collectionManager, IServerConfigurationManager config, ILogger logger)
         {
         {
@@ -354,6 +354,7 @@ namespace Emby.Server.Implementations.Collections
             _logger = logger;
             _logger = logger;
         }
         }
 
 
+        /// <inheritdoc />
         public async Task RunAsync()
         public async Task RunAsync()
         {
         {
             if (!_config.Configuration.CollectionsUpgraded && _config.Configuration.IsStartupWizardCompleted)
             if (!_config.Configuration.CollectionsUpgraded && _config.Configuration.IsStartupWizardCompleted)
@@ -377,39 +378,10 @@ namespace Emby.Server.Implementations.Collections
             }
             }
         }
         }
 
 
-        #region IDisposable Support
-        private bool disposedValue = false; // To detect redundant calls
-
-        protected virtual void Dispose(bool disposing)
-        {
-            if (!disposedValue)
-            {
-                if (disposing)
-                {
-                    // TODO: dispose managed state (managed objects).
-                }
-
-                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
-                // TODO: set large fields to null.
-
-                disposedValue = true;
-            }
-        }
-
-        // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
-        // ~CollectionManagerEntryPoint() {
-        //   // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
-        //   Dispose(false);
-        // }
-
-        // This code added to correctly implement the disposable pattern.
+        /// <inheritdoc />
         public void Dispose()
         public void Dispose()
         {
         {
-            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
-            Dispose(true);
-            // TODO: uncomment the following line if the finalizer is overridden above.
-            // GC.SuppressFinalize(this);
+            // Nothing to dispose
         }
         }
-        #endregion
     }
     }
 }
 }