Fix local locked and StopRefreshIfLocalMetadataFound logic

This commit is contained in:
Shadowghost 2024-05-21 23:08:00 +02:00
parent f3bf9bcdc8
commit 0b64426cf2

View File

@ -663,9 +663,7 @@ namespace MediaBrowser.Providers.Manager
temp.Item.Path = item.Path; temp.Item.Path = item.Path;
temp.Item.Id = item.Id; temp.Item.Id = item.Id;
var hasLocalBaseMetadataOrLocked = false;
var foundImageTypes = new List<ImageType>(); var foundImageTypes = new List<ImageType>();
foreach (var provider in providers.OfType<ILocalMetadataProvider<TItemType>>()) foreach (var provider in providers.OfType<ILocalMetadataProvider<TItemType>>())
{ {
var providerName = provider.GetType().Name; var providerName = provider.GetType().Name;
@ -714,12 +712,6 @@ namespace MediaBrowser.Providers.Manager
MergeData(localItem, temp, Array.Empty<MetadataField>(), false, true); MergeData(localItem, temp, Array.Empty<MetadataField>(), false, true);
refreshResult.UpdateType |= ItemUpdateType.MetadataImport; refreshResult.UpdateType |= ItemUpdateType.MetadataImport;
// Only one local provider allowed per item
if (item.IsLocked || localItem.Item.IsLocked || HasBaseMetadata(localItem.Item))
{
hasLocalBaseMetadataOrLocked = true;
}
break; 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<IRemoteMetadataProvider<TItemType, TIdType>>(), cancellationToken) var remoteResult = await ExecuteRemoteProviders(temp, logName, false, id, providers.OfType<IRemoteMetadataProvider<TItemType, TIdType>>(), cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -751,6 +745,12 @@ namespace MediaBrowser.Providers.Manager
if (providers.Any(i => i is not ICustomMetadataProvider)) if (providers.Any(i => i is not ICustomMetadataProvider))
{ {
if (refreshResult.UpdateType > ItemUpdateType.None) if (refreshResult.UpdateType > ItemUpdateType.None)
{
if (isLocalLocked)
{
MergeData(temp, metadata, item.LockedFields, true, true);
}
else
{ {
if (!options.RemoveOldMetadata) if (!options.RemoveOldMetadata)
{ {
@ -758,7 +758,9 @@ namespace MediaBrowser.Providers.Manager
MergeData(temp, metadata, Array.Empty<MetadataField>(), false, false); MergeData(temp, metadata, Array.Empty<MetadataField>(), 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);
}
} }
} }