< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Library.Validators.CollectionPosterVerifyPostScanTask
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Library/Validators/CollectionPosterVerifyPostScanTask.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 64
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 7/27/2026 - 12:16:14 AM Line coverage: 100% (15/15) Branch coverage: 100% (4/4) Total lines: 64 7/27/2026 - 12:16:14 AM Line coverage: 100% (15/15) Branch coverage: 100% (4/4) Total lines: 64

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Run()100%44100%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Library/Validators/CollectionPosterVerifyPostScanTask.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using MediaBrowser.Controller.Entities;
 6using MediaBrowser.Controller.Library;
 7using MediaBrowser.Model.Entities;
 8using Microsoft.Extensions.Logging;
 9
 10namespace Emby.Server.Implementations.Library.Validators;
 11
 12/// <summary>
 13/// Ensures top-level library folders have a primary poster after scans.
 14/// Poster extraction is attempted before library scanning. When a library is
 15/// empty at that point, no poster can be extracted. This post-scan task reruns
 16/// metadata extraction for top-level folders that are still missing images.
 17/// </summary>
 18public class CollectionPosterVerifyPostScanTask : ILibraryPostScanTask
 19{
 20    private readonly ILibraryManager _libraryManager;
 21    private readonly ILogger<CollectionPosterVerifyPostScanTask> _logger;
 22
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="CollectionPosterVerifyPostScanTask" /> class.
 25    /// </summary>
 26    /// <param name="libraryManager">The library manager.</param>
 27    /// <param name="logger">The logger.</param>
 28    public CollectionPosterVerifyPostScanTask(
 29        ILibraryManager libraryManager,
 30        ILogger<CollectionPosterVerifyPostScanTask> logger)
 31    {
 2232        _libraryManager = libraryManager;
 2233        _logger = logger;
 2234    }
 35
 36    /// <summary>
 37    /// Runs the specified progress.
 38    /// </summary>
 39    /// <param name="progress">The progress.</param>
 40    /// <param name="cancellationToken">The cancellation token.</param>
 41    /// <returns>Task.</returns>
 42    public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
 43    {
 1844        var libraries = _libraryManager.GetUserRootFolder().Children.OfType<CollectionFolder>().ToList();
 1845        var totalLibraries = libraries.Count;
 1846        var processedLibraries = 0;
 47
 4248        foreach (var library in libraries)
 49        {
 350            cancellationToken.ThrowIfCancellationRequested();
 51
 352            if (!library.HasImage(ImageType.Primary))
 53            {
 354                _logger.LogDebug("Library {LibraryName} is missing a primary image. Refreshing metadata.", library.Name)
 355                await library.RefreshMetadata(cancellationToken).ConfigureAwait(false);
 56            }
 57
 358            processedLibraries++;
 359            progress.Report((double)processedLibraries / totalLibraries * 100);
 60        }
 61
 1862        progress.Report(100);
 1863    }
 64}