Fix possible race condition

This commit is contained in:
Bond_009 2020-02-28 20:34:10 +01:00
parent d1e1aef5f7
commit e699e5d405
2 changed files with 9 additions and 10 deletions

View File

@ -970,20 +970,18 @@ namespace MediaBrowser.Providers.Manager
var id = item.Id;
_logger.LogInformation("OnRefreshProgress {0} {1}", id.ToString("N", CultureInfo.InvariantCulture), progress);
if (_activeRefreshes.TryAdd(id, progress))
{
RefreshProgress?.Invoke(this, new GenericEventArgs<Tuple<BaseItem, double>>(new Tuple<BaseItem, double>(item, progress)));
}
else
{
// TODO: Need to hunt down the conditions for this happening
throw new Exception(
// TODO: Need to hunt down the conditions for this happening
_activeRefreshes.AddOrUpdate(
id,
(_) => throw new Exception(
string.Format(
CultureInfo.InvariantCulture,
"Refresh for item {0} {1} is not in progress",
item.GetType().Name,
item.Id.ToString("N", CultureInfo.InvariantCulture)));
}
item.Id.ToString("N", CultureInfo.InvariantCulture))),
(_, _) => progress);
RefreshProgress?.Invoke(this, new GenericEventArgs<Tuple<BaseItem, double>>(new Tuple<BaseItem, double>(item, progress)));
}
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue =

View File

@ -22,6 +22,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<!-- Code Analyzers-->