From 0b64426cf24eadde5c2c56d3e0b0b1ed47f09805 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Tue, 21 May 2024 23:08:00 +0200 Subject: [PATCH] Fix local locked and StopRefreshIfLocalMetadataFound logic --- .../Manager/MetadataService.cs | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 1314a6b42..21f339b7d 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -663,9 +663,7 @@ namespace MediaBrowser.Providers.Manager temp.Item.Path = item.Path; temp.Item.Id = item.Id; - var hasLocalBaseMetadataOrLocked = false; var foundImageTypes = new List(); - foreach (var provider in providers.OfType>()) { var providerName = provider.GetType().Name; @@ -714,12 +712,6 @@ namespace MediaBrowser.Providers.Manager MergeData(localItem, temp, Array.Empty(), false, true); refreshResult.UpdateType |= ItemUpdateType.MetadataImport; - // Only one local provider allowed per item - if (item.IsLocked || localItem.Item.IsLocked || HasBaseMetadata(localItem.Item)) - { - hasLocalBaseMetadataOrLocked = true; - } - break; } @@ -738,7 +730,9 @@ namespace MediaBrowser.Providers.Manager } } - if (options.ReplaceAllMetadata || !(hasLocalBaseMetadataOrLocked && item.StopRefreshIfLocalMetadataFound) || options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh) + var hasLocalBaseMetadata = HasBaseMetadata(temp.Item); + var isLocalLocked = temp.Item.IsLocked; + if (!isLocalLocked && !(hasLocalBaseMetadata && item.StopRefreshIfLocalMetadataFound) && (options.ReplaceAllMetadata || options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh)) { var remoteResult = await ExecuteRemoteProviders(temp, logName, false, id, providers.OfType>(), cancellationToken) .ConfigureAwait(false); @@ -752,13 +746,21 @@ namespace MediaBrowser.Providers.Manager { if (refreshResult.UpdateType > ItemUpdateType.None) { - if (!options.RemoveOldMetadata) + if (isLocalLocked) { - // Add existing metadata to provider result if it does not exist there - MergeData(temp, metadata, Array.Empty(), false, false); + MergeData(temp, metadata, item.LockedFields, true, true); } + else + { + if (!options.RemoveOldMetadata) + { + // Add existing metadata to provider result if it does not exist there + MergeData(temp, metadata, Array.Empty(), false, false); + } - MergeData(temp, metadata, item.LockedFields, options.MetadataRefreshMode >= MetadataRefreshMode.Default || options.ReplaceAllMetadata, true); + var shouldReplace = options.MetadataRefreshMode >= MetadataRefreshMode.Default || options.ReplaceAllMetadata; + MergeData(temp, metadata, item.LockedFields, shouldReplace, true); + } } }