support refreshing collection folders through the api
This commit is contained in:
parent
088d04392f
commit
a018d28b12
|
@ -785,19 +785,7 @@ namespace MediaBrowser.Api.Images
|
|||
|
||||
await _providerManager.SaveImage(entity, memoryStream, mimeType, imageType, imageIndex, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
var user = entity as User;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
await _userManager.UpdateUser(user).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _libraryManager.UpdateItem(entity, ItemUpdateType.ImageUpdate, CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await entity.RefreshMetadata(CancellationToken.None, allowSlowProviders: false).ConfigureAwait(false);
|
||||
await entity.RefreshMetadata(CancellationToken.None, forceRefresh: true, forceSave: true, allowSlowProviders: false).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Controller.Dto;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using ServiceStack.ServiceHost;
|
||||
|
@ -221,8 +222,17 @@ namespace MediaBrowser.Api
|
|||
|
||||
if (folder != null)
|
||||
{
|
||||
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive,
|
||||
request.Forced).ConfigureAwait(false);
|
||||
// Collection folders don't validate their children so we'll have to simulate that here
|
||||
var collectionFolder = folder as CollectionFolder;
|
||||
|
||||
if (collectionFolder != null)
|
||||
{
|
||||
await RefreshCollectionFolderChildren(request, collectionFolder).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive, request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -230,5 +240,26 @@ namespace MediaBrowser.Api
|
|||
Logger.ErrorException("Error refreshing library", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the collection folder children.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="collectionFolder">The collection folder.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task RefreshCollectionFolderChildren(RefreshItem request, CollectionFolder collectionFolder)
|
||||
{
|
||||
foreach (var child in collectionFolder.Children.ToList())
|
||||
{
|
||||
await child.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
|
||||
var folder = child as Folder;
|
||||
|
||||
if (folder != null)
|
||||
{
|
||||
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive, request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user