diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index 1018053ccf..f1e9e6f9a6 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -100,9 +100,12 @@ namespace MediaBrowser.Api [Api(Description = "Refreshes metadata for an item")] public class RefreshItem : IReturnVoid { - [ApiMember(Name = "IsForced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = true, DataType = "bool", ParameterType = "query", Verb = "POST")] - public bool IsForced { get; set; } + [ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = true, DataType = "bool", ParameterType = "query", Verb = "POST")] + public bool Forced { get; set; } + [ApiMember(Name = "Recursive", Description = "Indicates if the refresh should occur recursively.", IsRequired = true, DataType = "bool", ParameterType = "query", Verb = "POST")] + public bool Recursive { get; set; } + [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public string Id { get; set; } } @@ -323,7 +326,16 @@ namespace MediaBrowser.Api { var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager); - item.RefreshMetadata(CancellationToken.None, forceRefresh: request.IsForced); + var folder = item as Folder; + + if (folder != null) + { + folder.ValidateChildren(new Progress(), CancellationToken.None, request.Recursive, request.Forced); + } + else + { + item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced); + } } /// diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 70f3548f38..64e5da92e7 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -55,8 +55,9 @@ namespace MediaBrowser.Controller.Entities /// The progress. /// The cancellation token. /// if set to true [recursive]. + /// if set to true [force refresh metadata]. /// Task. - protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null) + protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false) { //we don't directly validate our children //but we do need to clear out the index cache... diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 66a4ca215f..16bfff564b 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -554,8 +554,9 @@ namespace MediaBrowser.Controller.Entities /// The progress. /// The cancellation token. /// if set to true [recursive]. + /// if set to true [force refresh metadata]. /// Task. - public async Task ValidateChildren(IProgress progress, CancellationToken cancellationToken, bool? recursive = null) + public async Task ValidateChildren(IProgress progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false) { cancellationToken.ThrowIfCancellationRequested(); @@ -575,7 +576,7 @@ namespace MediaBrowser.Controller.Entities var linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(innerCancellationTokenSource.Token, cancellationToken); - await ValidateChildrenInternal(progress, linkedCancellationTokenSource.Token, recursive).ConfigureAwait(false); + await ValidateChildrenInternal(progress, linkedCancellationTokenSource.Token, recursive, forceRefreshMetadata).ConfigureAwait(false); } catch (OperationCanceledException ex) { @@ -606,8 +607,9 @@ namespace MediaBrowser.Controller.Entities /// The progress. /// The cancellation token. /// if set to true [recursive]. + /// if set to true [force refresh metadata]. /// Task. - protected async virtual Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null) + protected async virtual Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false) { // Nothing to do here if (LocationType != LocationType.FileSystem) @@ -723,7 +725,7 @@ namespace MediaBrowser.Controller.Entities cancellationToken.ThrowIfCancellationRequested(); - await RefreshChildren(validChildren, progress, cancellationToken, recursive).ConfigureAwait(false); + await RefreshChildren(validChildren, progress, cancellationToken, recursive, forceRefreshMetadata).ConfigureAwait(false); progress.Report(100); } @@ -735,8 +737,9 @@ namespace MediaBrowser.Controller.Entities /// The progress. /// The cancellation token. /// if set to true [recursive]. + /// if set to true [force refresh metadata]. /// Task. - private async Task RefreshChildren(IEnumerable> children, IProgress progress, CancellationToken cancellationToken, bool? recursive) + private async Task RefreshChildren(IEnumerable> children, IProgress progress, CancellationToken cancellationToken, bool? recursive, bool forceRefreshMetadata = false) { var list = children.ToList(); @@ -760,7 +763,7 @@ namespace MediaBrowser.Controller.Entities var child = currentTuple.Item1; //refresh it - await child.RefreshMetadata(cancellationToken, resetResolveArgs: child.IsFolder, forceSave: currentTuple.Item2).ConfigureAwait(false); + await child.RefreshMetadata(cancellationToken, resetResolveArgs: child.IsFolder, forceSave: currentTuple.Item2, forceRefresh: forceRefreshMetadata).ConfigureAwait(false); // Refresh children if a folder and the item changed or recursive is set to true var refreshChildren = child.IsFolder && (currentTuple.Item2 || (recursive.HasValue && recursive.Value));