| | 1 | | using System; |
| | 2 | | using MediaBrowser.Controller.Entities; |
| | 3 | | using MediaBrowser.Controller.Library; |
| | 4 | | using Microsoft.Extensions.Logging; |
| | 5 | |
|
| | 6 | | namespace 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") |
| | 13 | | internal 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 | | { |
| 0 | 21 | | _logger = logger; |
| 0 | 22 | | _libraryManager = libraryManager; |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <inheritdoc/> |
| | 26 | | public void Perform() |
| | 27 | | { |
| 0 | 28 | | var virtualFolders = _libraryManager.GetVirtualFolders(false); |
| 0 | 29 | | _logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries"); |
| 0 | 30 | | foreach (var virtualFolder in virtualFolders) |
| | 31 | | { |
| | 32 | | // Some virtual folders don't have a proper item id. |
| 0 | 33 | | if (!Guid.TryParse(virtualFolder.ItemId, out var folderId)) |
| | 34 | | { |
| | 35 | | continue; |
| | 36 | | } |
| | 37 | |
|
| 0 | 38 | | var libraryOptions = virtualFolder.LibraryOptions; |
| 0 | 39 | | 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. |
| 0 | 41 | | collectionFolder.UpdateLibraryOptions(libraryOptions); |
| 0 | 42 | | _logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name); |
| | 43 | | } |
| 0 | 44 | | } |
| | 45 | | } |