| | 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 | | 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 | | { |
| 0 | 18 | | _logger = logger; |
| 0 | 19 | | _libraryManager = libraryManager; |
| 0 | 20 | | } |
| | 21 | |
|
| | 22 | | /// <inheritdoc/> |
| 0 | 23 | | public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}"); |
| | 24 | |
|
| | 25 | | /// <inheritdoc/> |
| 0 | 26 | | public string Name => "RemoveDownloadImagesInAdvance"; |
| | 27 | |
|
| | 28 | | /// <inheritdoc/> |
| 0 | 29 | | public bool PerformOnNewInstall => false; |
| | 30 | |
|
| | 31 | | /// <inheritdoc/> |
| | 32 | | public void Perform() |
| | 33 | | { |
| 0 | 34 | | var virtualFolders = _libraryManager.GetVirtualFolders(false); |
| 0 | 35 | | _logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries"); |
| 0 | 36 | | foreach (var virtualFolder in virtualFolders) |
| | 37 | | { |
| | 38 | | // Some virtual folders don't have a proper item id. |
| 0 | 39 | | if (!Guid.TryParse(virtualFolder.ItemId, out var folderId)) |
| | 40 | | { |
| | 41 | | continue; |
| | 42 | | } |
| | 43 | |
|
| 0 | 44 | | var libraryOptions = virtualFolder.LibraryOptions; |
| 0 | 45 | | 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 |
| 0 | 47 | | collectionFolder.UpdateLibraryOptions(libraryOptions); |
| 0 | 48 | | _logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name); |
| | 49 | | } |
| 0 | 50 | | } |
| | 51 | | } |
| | 52 | | } |