using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Server.Migrations.Routines
{
///
/// Removes the old 'RemoveDownloadImagesInAdvance' from library options.
///
internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
{
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
public RemoveDownloadImagesInAdvance(ILogger logger, ILibraryManager libraryManager)
{
_logger = logger;
_libraryManager = libraryManager;
}
///
public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}");
///
public string Name => "RemoveDownloadImagesInAdvance";
///
public bool PerformOnNewInstall => false;
///
public void Perform()
{
var virtualFolders = _libraryManager.GetVirtualFolders(false);
_logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
foreach (var virtualFolder in virtualFolders)
{
var libraryOptions = virtualFolder.LibraryOptions;
var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(virtualFolder.ItemId);
// The property no longer exists in LibraryOptions, so we just re-save the options to get old data removed.
collectionFolder.UpdateLibraryOptions(libraryOptions);
_logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
}
}
}
}