Browse Source

use scheduled task when plugins ask for a library refresh

Luke Pulverenti 12 years ago
parent
commit
bc833492f0

+ 13 - 1
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -758,7 +758,19 @@ namespace MediaBrowser.Server.Implementations.Library
         /// <param name="progress">The progress.</param>
         /// <param name="cancellationToken">The cancellation token.</param>
         /// <returns>Task.</returns>
-        public async Task ValidateMediaLibrary(IProgress<double> progress, CancellationToken cancellationToken)
+        public Task ValidateMediaLibrary(IProgress<double> progress, CancellationToken cancellationToken)
+        {
+            // Just run the scheduled task so that the user can see it
+            return Task.Run(() => _taskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>());
+        }
+
+        /// <summary>
+        /// Validates the media library internal.
+        /// </summary>
+        /// <param name="progress">The progress.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        public async Task ValidateMediaLibraryInternal(IProgress<double> progress, CancellationToken cancellationToken)
         {
             _logger.Info("Validating media library");
 

+ 2 - 1
MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs

@@ -5,6 +5,7 @@ using System;
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using MediaBrowser.Server.Implementations.Library;
 
 namespace MediaBrowser.Server.Implementations.ScheduledTasks
 {
@@ -55,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
 
             progress.Report(0);
 
-            return _libraryManager.ValidateMediaLibrary(progress, cancellationToken);
+            return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
         }
 
         /// <summary>