Merge pull request #3196 from ferferga/images-advance

Remove "download images in advance" option
This commit is contained in:
Claus Vium 2020-11-10 10:54:23 +01:00 committed by GitHub
commit cdf979efef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 35 deletions

View File

@ -23,7 +23,8 @@ namespace Jellyfin.Server.Migrations
typeof(Routines.AddDefaultPluginRepository),
typeof(Routines.MigrateUserDb),
typeof(Routines.ReaddDefaultPluginRepository),
typeof(Routines.MigrateDisplayPreferencesDb)
typeof(Routines.MigrateDisplayPreferencesDb),
typeof(Routines.RemoveDownloadImagesInAdvance)
};
/// <summary>

View File

@ -0,0 +1,46 @@
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()
{
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);
}
}
}
}

View File

@ -17,8 +17,6 @@ namespace MediaBrowser.Model.Configuration
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
public bool DownloadImagesInAdvance { get; set; }
public MediaPathInfo[] PathInfos { get; set; }
public bool SaveLocalMetadata { get; set; }

View File

@ -517,13 +517,8 @@ namespace MediaBrowser.Providers.Manager
return true;
}
}
if (libraryOptions.DownloadImagesInAdvance)
{
return false;
}
return true;
// We always want to use prefetched images
return false;
}
private void SaveImageStub(BaseItem item, ImageType imageType, IEnumerable<string> urls)

View File

@ -252,7 +252,13 @@ namespace MediaBrowser.Providers.Manager
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
{
await AddPersonImageAsync(personEntity, libraryOptions, person.ImageUrl, cancellationToken).ConfigureAwait(false);
personEntity.SetImage(
new ItemImageInfo
{
Path = person.ImageUrl,
Type = ImageType.Primary
},
0);
saveEntity = true;
updateType |= ItemUpdateType.ImageUpdate;
@ -266,30 +272,6 @@ namespace MediaBrowser.Providers.Manager
}
}
private async Task AddPersonImageAsync(Person personEntity, LibraryOptions libraryOptions, string imageUrl, CancellationToken cancellationToken)
{
if (libraryOptions.DownloadImagesInAdvance)
{
try
{
await ProviderManager.SaveImage(personEntity, imageUrl, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
return;
}
catch (Exception ex)
{
Logger.LogError(ex, "Error in AddPersonImage");
}
}
personEntity.SetImage(
new ItemImageInfo
{
Path = imageUrl,
Type = ImageType.Primary
},
0);
}
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{
item.AfterMetadataRefresh();