Ver código fonte

Merge pull request #3196 from ferferga/images-advance

Remove "download images in advance" option
Claus Vium 4 anos atrás
pai
commit
cdf979efef

+ 2 - 1
Jellyfin.Server/Migrations/MigrationRunner.cs

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

+ 46 - 0
Jellyfin.Server/Migrations/Routines/RemoveDownloadImagesInAdvance.cs

@@ -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);
+            }
+        }
+    }
+}

+ 0 - 2
MediaBrowser.Model/Configuration/LibraryOptions.cs

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

+ 2 - 7
MediaBrowser.Providers/Manager/ItemImageProvider.cs

@@ -517,13 +517,8 @@ namespace MediaBrowser.Providers.Manager
                     return true;
                     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)
         private void SaveImageStub(BaseItem item, ImageType imageType, IEnumerable<string> urls)

+ 7 - 25
MediaBrowser.Providers/Manager/MetadataService.cs

@@ -252,7 +252,13 @@ namespace MediaBrowser.Providers.Manager
 
 
                     if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
                     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;
                         saveEntity = true;
                         updateType |= ItemUpdateType.ImageUpdate;
                         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)
         protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
         {
         {
             item.AfterMetadataRefresh();
             item.AfterMetadataRefresh();