use scheduled task when plugins ask for a library refresh

This commit is contained in:
Luke Pulverenti 2013-04-14 15:39:25 -04:00
parent 92af49d810
commit bc833492f0
2 changed files with 15 additions and 2 deletions

View File

@ -758,7 +758,19 @@ namespace MediaBrowser.Server.Implementations.Library
/// <param name="progress">The progress.</param> /// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns> /// <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"); _logger.Info("Validating media library");

View File

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