2020-11-09 23:20:12 +00:00
|
|
|
using System;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
namespace Jellyfin.Server.Migrations.Routines
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Removes the old 'RemoveDownloadImagesInAdvance' from library options.
|
|
|
|
/// </summary>
|
|
|
|
internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
|
|
|
|
{
|
|
|
|
private readonly ILogger<RemoveDownloadImagesInAdvance> _logger;
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
|
|
|
public RemoveDownloadImagesInAdvance(ILogger<RemoveDownloadImagesInAdvance> logger, ILibraryManager libraryManager)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}");
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public string Name => "RemoveDownloadImagesInAdvance";
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public bool PerformOnNewInstall => false;
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public void Perform()
|
|
|
|
{
|
2020-11-10 09:24:05 +00:00
|
|
|
var virtualFolders = _libraryManager.GetVirtualFolders(false);
|
2020-11-09 23:20:12 +00:00
|
|
|
_logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
|
2020-11-10 09:24:05 +00:00
|
|
|
foreach (var virtualFolder in virtualFolders)
|
2020-11-09 23:20:12 +00:00
|
|
|
{
|
2020-12-02 00:36:36 +00:00
|
|
|
// Some virtual folders don't have a proper item id.
|
|
|
|
if (!Guid.TryParse(virtualFolder.ItemId, out var folderId))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-10 09:24:05 +00:00
|
|
|
var libraryOptions = virtualFolder.LibraryOptions;
|
2020-12-02 00:36:36 +00:00
|
|
|
var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(folderId);
|
2020-11-09 23:20:12 +00:00
|
|
|
// The property no longer exists in LibraryOptions, so we just re-save the options to get old data removed.
|
2020-11-10 09:24:05 +00:00
|
|
|
collectionFolder.UpdateLibraryOptions(libraryOptions);
|
|
|
|
_logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
|
2020-11-09 23:20:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|