mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
bulk save items when possible
This commit is contained in:
@@ -691,16 +691,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
var saveTasks = new List<Task>();
|
||||
await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (var item in newItems)
|
||||
{
|
||||
if (saveTasks.Count > 50)
|
||||
{
|
||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
||||
saveTasks.Clear();
|
||||
}
|
||||
|
||||
if (!_children.TryAdd(item.Id, item))
|
||||
{
|
||||
Logger.Error("Failed to add {0}", item.Name);
|
||||
@@ -709,12 +703,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
Logger.Debug("** " + item.Name + " Added to library.");
|
||||
}
|
||||
|
||||
saveTasks.Add(LibraryManager.CreateItem(item, CancellationToken.None));
|
||||
}
|
||||
|
||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
||||
|
||||
await LibraryManager.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
//force the indexes to rebuild next time
|
||||
|
||||
Reference in New Issue
Block a user