Add endpoint to update all items in library

This commit is contained in:
Jesús Higueras
2020-03-25 17:26:53 +01:00
committed by Vasily
parent b9fc0d2628
commit fe480caf54
3 changed files with 35 additions and 0 deletions

View File

@@ -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>