mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 20:38:24 +02:00
added sync help buttons
This commit is contained in:
parent
83ec91f836
commit
82fe244fa1
1 changed files with 28 additions and 29 deletions
|
@ -563,50 +563,49 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var children = ActualChildren.ToList();
|
var children = ActualChildren.ToList();
|
||||||
|
|
||||||
var percentages = new Dictionary<Guid, double>(children.Count);
|
var percentages = new Dictionary<Guid, double>(children.Count);
|
||||||
|
var numComplete = 0;
|
||||||
var tasks = new List<Task>();
|
var count = children.Count;
|
||||||
|
|
||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
{
|
{
|
||||||
if (tasks.Count >= 2)
|
|
||||||
{
|
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
tasks.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
var innerProgress = new ActionableProgress<double>();
|
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
|
||||||
var currentChild = child;
|
|
||||||
innerProgress.RegisterAction(p =>
|
|
||||||
{
|
|
||||||
lock (percentages)
|
|
||||||
{
|
|
||||||
percentages[currentChild.Id] = p / 100;
|
|
||||||
|
|
||||||
var percent = percentages.Values.Sum();
|
|
||||||
percent /= children.Count;
|
|
||||||
percent *= 100;
|
|
||||||
progress.Report(percent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (child.IsFolder)
|
if (child.IsFolder)
|
||||||
{
|
{
|
||||||
|
var innerProgress = new ActionableProgress<double>();
|
||||||
|
|
||||||
|
// Avoid implicitly captured closure
|
||||||
|
var currentChild = child;
|
||||||
|
innerProgress.RegisterAction(p =>
|
||||||
|
{
|
||||||
|
lock (percentages)
|
||||||
|
{
|
||||||
|
percentages[currentChild.Id] = p / 100;
|
||||||
|
|
||||||
|
var innerPercent = percentages.Values.Sum();
|
||||||
|
innerPercent /= count;
|
||||||
|
innerPercent *= 100;
|
||||||
|
progress.Report(innerPercent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await RefreshChildMetadata(child, refreshOptions, recursive, innerProgress, cancellationToken)
|
await RefreshChildMetadata(child, refreshOptions, recursive, innerProgress, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Avoid implicitly captured closure
|
await RefreshChildMetadata(child, refreshOptions, false, new Progress<double>(), cancellationToken)
|
||||||
var taskChild = child;
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
tasks.Add(Task.Run(async () => await RefreshChildMetadata(taskChild, refreshOptions, false, innerProgress, cancellationToken).ConfigureAwait(false), cancellationToken));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numComplete++;
|
||||||
|
double percent = numComplete;
|
||||||
|
percent /= count;
|
||||||
|
percent *= 100;
|
||||||
|
|
||||||
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue