mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Add endpoint to update all items in library
This commit is contained in:
parent
b9fc0d2628
commit
fe480caf54
@ -1911,6 +1911,34 @@ namespace Emby.Server.Implementations.Library
|
||||
UpdateItems(new[] { item }, parent, updateReason, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates everything in the database.
|
||||
/// </summary>
|
||||
public void UpdateAll()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
var items = ItemRepository.GetItemList(new InternalItemsQuery {
|
||||
Recursive = true
|
||||
});
|
||||
foreach (var item in items)
|
||||
{
|
||||
_logger.LogDebug("Updating item {Name} ({ItemId})",
|
||||
item.Name,
|
||||
item.Id);
|
||||
try
|
||||
{
|
||||
item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Updating item {ItemId} failed", item.Id);
|
||||
}
|
||||
}
|
||||
_logger.LogDebug("All items have been updated");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports the item removed.
|
||||
/// </summary>
|
||||
|
@ -198,6 +198,12 @@ namespace MediaBrowser.Api
|
||||
|
||||
public void Post(UpdateItem request)
|
||||
{
|
||||
if (request.ItemId == "*")
|
||||
{
|
||||
// Special case: Refresh everything in database. Probably not a great idea to run often.
|
||||
_libraryManager.UpdateAll();
|
||||
return;
|
||||
}
|
||||
var item = _libraryManager.GetItemById(request.ItemId);
|
||||
|
||||
var newLockData = request.LockData ?? false;
|
||||
|
@ -196,6 +196,7 @@ namespace MediaBrowser.Controller.Library
|
||||
/// </summary>
|
||||
void UpdateItems(IEnumerable<BaseItem> items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken);
|
||||
void UpdateItem(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken);
|
||||
void UpdateAll();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the item.
|
||||
|
Loading…
Reference in New Issue
Block a user