The Free Software Media System - Server Backend & API
added sync help buttons
Luke Pulverenti82fe244fa140
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex cf85cbb0d1..039318f1d6 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -563,50 +563,49 @@ namespace MediaBrowser.Controller.Entitiesvar children = ActualChildren.ToList();var percentages = new Dictionary<Guid, double>(children.Count);-- var tasks = new List<Task>();+ var numComplete = 0;+ var count = children.Count;foreach (var child in children){- if (tasks.Count >= 2)- {- await Task.WhenAll(tasks).ConfigureAwait(false);- tasks.Clear();- }-cancellationToken.ThrowIfCancellationRequested();- var innerProgress = new ActionableProgress<double>();- // Avoid implicitly captured closure- var currentChild = child;- innerProgress.RegisterAction(p =>+ if (child.IsFolder){- lock (percentages)+ var innerProgress = new ActionableProgress<double>();++ // Avoid implicitly captured closure+ var currentChild = child;+ innerProgress.RegisterAction(p =>{- percentages[currentChild.Id] = p / 100;+ lock (percentages)+ {+ percentages[currentChild.Id] = p / 100;- var percent = percentages.Values.Sum();- percent /= children.Count;- percent *= 100;- progress.Report(percent);- }- });+ var innerPercent = percentages.Values.Sum();+ innerPercent /= count;+ innerPercent *= 100;+ progress.Report(innerPercent);+ }+ });- if (child.IsFolder)- {await RefreshChildMetadata(child, refreshOptions, recursive, innerProgress, cancellationToken).ConfigureAwait(false);}else{- // Avoid implicitly captured closure- var taskChild = child;-- tasks.Add(Task.Run(async () => await RefreshChildMetadata(taskChild, refreshOptions, false, innerProgress, cancellationToken).ConfigureAwait(false), cancellationToken));+ await RefreshChildMetadata(child, refreshOptions, false, new Progress<double>(), cancellationToken)+ .ConfigureAwait(false);}++ numComplete++;+ double percent = numComplete;+ percent /= count;+ percent *= 100;++ progress.Report(percent);}- await Task.WhenAll(tasks).ConfigureAwait(false);progress.Report(100);}