< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Routines.RemoveDownloadImagesInAdvance
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/RemoveDownloadImagesInAdvance.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 45
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Perform()0%4260%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/RemoveDownloadImagesInAdvance.cs

#LineLine coverage
 1using System;
 2using MediaBrowser.Controller.Entities;
 3using MediaBrowser.Controller.Library;
 4using Microsoft.Extensions.Logging;
 5
 6namespace Jellyfin.Server.Migrations.Routines;
 7
 8/// <summary>
 9/// Removes the old 'RemoveDownloadImagesInAdvance' from library options.
 10/// </summary>
 11#pragma warning disable CS0618 // Type or member is obsolete
 12[JellyfinMigration("2025-04-20T13:00:00", nameof(RemoveDownloadImagesInAdvance), "A81F75E0-8F43-416F-A5E8-516CCAB4D8CC")
 13internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
 14#pragma warning restore CS0618 // Type or member is obsolete
 15{
 16    private readonly ILogger<RemoveDownloadImagesInAdvance> _logger;
 17    private readonly ILibraryManager _libraryManager;
 18
 19    public RemoveDownloadImagesInAdvance(ILogger<RemoveDownloadImagesInAdvance> logger, ILibraryManager libraryManager)
 20    {
 021        _logger = logger;
 022        _libraryManager = libraryManager;
 023    }
 24
 25    /// <inheritdoc/>
 26    public void Perform()
 27    {
 028        var virtualFolders = _libraryManager.GetVirtualFolders(false);
 029        _logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
 030        foreach (var virtualFolder in virtualFolders)
 31        {
 32            // Some virtual folders don't have a proper item id.
 033            if (!Guid.TryParse(virtualFolder.ItemId, out var folderId))
 34            {
 35                continue;
 36            }
 37
 038            var libraryOptions = virtualFolder.LibraryOptions;
 039            var collectionFolder = _libraryManager.GetItemById<CollectionFolder>(folderId) ?? throw new InvalidOperation
 40            // The property no longer exists in LibraryOptions, so we just re-save the options to get old data removed.
 041            collectionFolder.UpdateLibraryOptions(libraryOptions);
 042            _logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
 43        }
 044    }
 45}