Merge pull request #16419 from Shadowghost/extend-segment-interface
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI Publish / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
OpenAPI Publish / OpenAPI - Publish Artifact (push) Waiting to run
OpenAPI Publish / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run

Add callback for segment data pruning to IMediaSegmentProvider
This commit is contained in:
Niels van Velzen
2026-04-02 22:00:01 +02:00
committed by GitHub
2 changed files with 23 additions and 1 deletions

View File

@@ -182,6 +182,18 @@ public class MediaSegmentManager : IMediaSegmentManager
/// <inheritdoc />
public async Task DeleteSegmentsAsync(Guid itemId, CancellationToken cancellationToken)
{
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);
}
}
var db = await _dbProvider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
await using (db.ConfigureAwait(false))
{

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