< 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: 15
Coverable lines: 15
Total lines: 52
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%
get_Id()100%210%
get_Name()100%210%
get_PerformOnNewInstall()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    internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
 12    {
 13        private readonly ILogger<RemoveDownloadImagesInAdvance> _logger;
 14        private readonly ILibraryManager _libraryManager;
 15
 16        public RemoveDownloadImagesInAdvance(ILogger<RemoveDownloadImagesInAdvance> logger, ILibraryManager libraryManag
 17        {
 018            _logger = logger;
 019            _libraryManager = libraryManager;
 020        }
 21
 22        /// <inheritdoc/>
 023        public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}");
 24
 25        /// <inheritdoc/>
 026        public string Name => "RemoveDownloadImagesInAdvance";
 27
 28        /// <inheritdoc/>
 029        public bool PerformOnNewInstall => false;
 30
 31        /// <inheritdoc/>
 32        public void Perform()
 33        {
 034            var virtualFolders = _libraryManager.GetVirtualFolders(false);
 035            _logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
 036            foreach (var virtualFolder in virtualFolders)
 37            {
 38                // Some virtual folders don't have a proper item id.
 039                if (!Guid.TryParse(virtualFolder.ItemId, out var folderId))
 40                {
 41                    continue;
 42                }
 43
 044                var libraryOptions = virtualFolder.LibraryOptions;
 045                var collectionFolder = _libraryManager.GetItemById<CollectionFolder>(folderId) ?? throw new InvalidOpera
 46                // The property no longer exists in LibraryOptions, so we just re-save the options to get old data remov
 047                collectionFolder.UpdateLibraryOptions(libraryOptions);
 048                _logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
 49            }
 050        }
 51    }
 52}