Add callback for segment data pruning to IMediaSegmentProvider

This commit is contained in:
Shadowghost
2026-03-14 19:58:43 +01:00
parent d65960fe5d
commit 98bbc26c5e
2 changed files with 26 additions and 1 deletions

View File

@@ -187,6 +187,18 @@ public class MediaSegmentManager : IMediaSegmentManager
{
await db.MediaSegments.Where(e => e.ItemId.Equals(itemId)).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false);
}
foreach (var provider in _segmentProviders)
{
try
{
await provider.CleanupExtractedData(itemId, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.LogError(ex, "Provider {ProviderName} failed to clean up extracted data for item {ItemId}", provider.Name, itemId);
}
}
}
/// <inheritdoc />

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
@@ -31,4 +32,16 @@ public interface IMediaSegmentProvider
/// <param name="item">The base item to extract segments from.</param>
/// <returns>True if item is supported, otherwise false.</returns>
ValueTask<bool> Supports(BaseItem item);
/// <summary>
/// Called when extracted segment data for an item is being pruned.
/// Providers should delete any cached analysis data they hold for the given item.
/// </summary>
/// <param name="itemId">The item whose data is being pruned.</param>
/// <param name="cancellationToken">Abort token.</param>
/// <returns>A task representing the asynchronous cleanup operation.</returns>
Task CleanupExtractedData(Guid itemId, CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}