Only update if actively refreshing (#11341)
This commit is contained in:
parent
7d28d08e08
commit
31e0756c0c
|
@ -460,15 +460,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
progress.Report(percent);
|
||||
|
||||
// TODO: this is sometimes being called after the refresh has completed.
|
||||
try
|
||||
{
|
||||
ProviderManager.OnRefreshProgress(folder, percent);
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.LogError(e, "Error refreshing folder");
|
||||
}
|
||||
ProviderManager.OnRefreshProgress(folder, percent);
|
||||
});
|
||||
|
||||
if (validChildrenNeedGeneration)
|
||||
|
@ -500,15 +492,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
if (recursive)
|
||||
{
|
||||
// TODO: this is sometimes being called after the refresh has completed.
|
||||
try
|
||||
{
|
||||
ProviderManager.OnRefreshProgress(folder, percent);
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.LogError(e, "Error refreshing folder");
|
||||
}
|
||||
ProviderManager.OnRefreshProgress(folder, percent);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -968,16 +968,13 @@ namespace MediaBrowser.Providers.Manager
|
|||
var id = item.Id;
|
||||
_logger.LogDebug("OnRefreshProgress {Id:N} {Progress}", id, progress);
|
||||
|
||||
// TODO: Need to hunt down the conditions for this happening
|
||||
_activeRefreshes.AddOrUpdate(
|
||||
id,
|
||||
_ => throw new InvalidOperationException(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Cannot update refresh progress of item '{0}' ({1}) because a refresh for this item is not running",
|
||||
item.GetType().Name,
|
||||
item.Id.ToString("N", CultureInfo.InvariantCulture))),
|
||||
(_, _) => progress);
|
||||
if (!_activeRefreshes.TryGetValue(id, out var current)
|
||||
|| progress <= current
|
||||
|| !_activeRefreshes.TryUpdate(id, progress, current))
|
||||
{
|
||||
// Item isn't currently refreshing, or update was received out-of-order, so don't trigger event.
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user