From b96b2e69c23cff03e11ab5c222ec98f3fe89586c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 12 May 2013 21:46:36 -0400 Subject: [PATCH] fixes #258 - Provide a "Refresh This" Function --- MediaBrowser.Api/LibraryService.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index a6e7598aaa..d5d90cdb25 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Controller.Persistence; +using System.Threading; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Querying; using ServiceStack.ServiceHost; using System; @@ -36,6 +38,12 @@ namespace MediaBrowser.Api public int? Limit { get; set; } } + [Route("/Library/Refresh", "POST")] + [Api(Description = "Starts a library scan")] + public class RefreshLibrary : IReturnVoid + { + } + /// /// Class LibraryService /// @@ -46,13 +54,17 @@ namespace MediaBrowser.Api /// private readonly IItemRepository _itemRepo; + private readonly ILibraryManager _libraryManager; + /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The item repo. - public LibraryService(IItemRepository itemRepo) + /// The library manager. + public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager) { _itemRepo = itemRepo; + _libraryManager = libraryManager; } /// @@ -67,6 +79,15 @@ namespace MediaBrowser.Api return ToOptimizedResult(result); } + /// + /// Posts the specified request. + /// + /// The request. + public void Post(RefreshLibrary request) + { + _libraryManager.ValidateMediaLibrary(new Progress(), CancellationToken.None); + } + /// /// Gets the critic reviews async. ///