mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
fix: don't allow exceptions to propagate from Refresh progress event handlers (#9228)
This commit is contained in:
parent
9e155eacea
commit
9eaad18c2c
@ -910,20 +910,35 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void OnRefreshStart(BaseItem item)
|
public void OnRefreshStart(BaseItem item)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("OnRefreshStart {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
_logger.LogDebug("OnRefreshStart {Item:N}", item.Id);
|
||||||
_activeRefreshes[item.Id] = 0;
|
_activeRefreshes[item.Id] = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
RefreshStarted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
|
RefreshStarted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// EventHandlers should never propagate exceptions, but we have little control over plugins...
|
||||||
|
_logger.LogError(ex, "Invoking {RefreshEvent} event handlers failed", nameof(RefreshStarted));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void OnRefreshComplete(BaseItem item)
|
public void OnRefreshComplete(BaseItem item)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("OnRefreshComplete {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
_logger.LogDebug("OnRefreshComplete {Item:N}", item.Id);
|
||||||
|
_activeRefreshes.TryRemove(item.Id, out _);
|
||||||
_activeRefreshes.Remove(item.Id, out _);
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
RefreshCompleted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
|
RefreshCompleted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// EventHandlers should never propagate exceptions, but we have little control over plugins...
|
||||||
|
_logger.LogError(ex, "Invoking {RefreshEvent} event handlers failed", nameof(RefreshCompleted));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public double? GetRefreshProgress(Guid id)
|
public double? GetRefreshProgress(Guid id)
|
||||||
@ -940,12 +955,12 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
public void OnRefreshProgress(BaseItem item, double progress)
|
public void OnRefreshProgress(BaseItem item, double progress)
|
||||||
{
|
{
|
||||||
var id = item.Id;
|
var id = item.Id;
|
||||||
_logger.LogDebug("OnRefreshProgress {Id} {Progress}", id.ToString("N", CultureInfo.InvariantCulture), progress);
|
_logger.LogDebug("OnRefreshProgress {Id:N} {Progress}", id, progress);
|
||||||
|
|
||||||
// TODO: Need to hunt down the conditions for this happening
|
// TODO: Need to hunt down the conditions for this happening
|
||||||
_activeRefreshes.AddOrUpdate(
|
_activeRefreshes.AddOrUpdate(
|
||||||
id,
|
id,
|
||||||
(_) => throw new InvalidOperationException(
|
_ => throw new InvalidOperationException(
|
||||||
string.Format(
|
string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"Cannot update refresh progress of item '{0}' ({1}) because a refresh for this item is not running",
|
"Cannot update refresh progress of item '{0}' ({1}) because a refresh for this item is not running",
|
||||||
@ -953,8 +968,16 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
item.Id.ToString("N", CultureInfo.InvariantCulture))),
|
item.Id.ToString("N", CultureInfo.InvariantCulture))),
|
||||||
(_, _) => progress);
|
(_, _) => progress);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
RefreshProgress?.Invoke(this, new GenericEventArgs<Tuple<BaseItem, double>>(new Tuple<BaseItem, double>(item, progress)));
|
RefreshProgress?.Invoke(this, new GenericEventArgs<Tuple<BaseItem, double>>(new Tuple<BaseItem, double>(item, progress)));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// EventHandlers should never propagate exceptions, but we have little control over plugins...
|
||||||
|
_logger.LogError(ex, "Invoking {RefreshEvent} event handlers failed", nameof(RefreshProgress));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void QueueRefresh(Guid itemId, MetadataRefreshOptions options, RefreshPriority priority)
|
public void QueueRefresh(Guid itemId, MetadataRefreshOptions options, RefreshPriority priority)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user