2
0

RemoveDownloadImagesInAdvance.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Controller.Library;
  4. using Microsoft.Extensions.Logging;
  5. namespace Jellyfin.Server.Migrations.Routines
  6. {
  7. /// <summary>
  8. /// Removes the old 'RemoveDownloadImagesInAdvance' from library options.
  9. /// </summary>
  10. internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
  11. {
  12. private readonly ILogger<RemoveDownloadImagesInAdvance> _logger;
  13. private readonly ILibraryManager _libraryManager;
  14. public RemoveDownloadImagesInAdvance(ILogger<RemoveDownloadImagesInAdvance> logger, ILibraryManager libraryManager)
  15. {
  16. _logger = logger;
  17. _libraryManager = libraryManager;
  18. }
  19. /// <inheritdoc/>
  20. public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}");
  21. /// <inheritdoc/>
  22. public string Name => "RemoveDownloadImagesInAdvance";
  23. /// <inheritdoc/>
  24. public bool PerformOnNewInstall => false;
  25. /// <inheritdoc/>
  26. public void Perform()
  27. {
  28. var virtualFolders = _libraryManager.GetVirtualFolders(false);
  29. _logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
  30. foreach (var virtualFolder in virtualFolders)
  31. {
  32. var libraryOptions = virtualFolder.LibraryOptions;
  33. var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(virtualFolder.ItemId);
  34. // The property no longer exists in LibraryOptions, so we just re-save the options to get old data removed.
  35. collectionFolder.UpdateLibraryOptions(libraryOptions);
  36. _logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
  37. }
  38. }
  39. }
  40. }