Only update if actively refreshing (#11341)

This commit is contained in:
Cody Robibero 2024-04-12 17:45:15 -06:00 committed by GitHub
parent 7d28d08e08
commit 31e0756c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 28 deletions

View File

@ -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);
}
});

View File

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