private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType, bool includeDisabled)
        {
            var options = GetMetadataOptions(item);

            try
            {
                if (!includeDisabled)
                {
                    if (!item.IsSaveLocalMetadataEnabled())
                    {
                        return(false);
                    }

                    if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }

                return(saver.IsEnabledFor(item, updateType));
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error in {0}.IsEnabledFor", ex, saver.Name);
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Determines whether [is saver enabled for item] [the specified saver].
        /// </summary>
        private bool IsSaverEnabledForItem(IMetadataSaver saver, BaseItem item, LibraryOptions libraryOptions, ItemUpdateType updateType, bool includeDisabled)
        {
            var options = GetMetadataOptions(item);

            try
            {
                if (!saver.IsEnabledFor(item, updateType))
                {
                    return(false);
                }

                if (!includeDisabled)
                {
                    if (libraryOptions.MetadataSavers == null)
                    {
                        if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
                        {
                            return(false);
                        }

                        if (!item.IsSaveLocalMetadataEnabled())
                        {
                            if (updateType >= ItemUpdateType.MetadataEdit)
                            {
                                var fileSaver = saver as IMetadataFileSaver;

                                // Manual edit occurred
                                // Even if save local is off, save locally anyway if the metadata file already exists
                                if (fileSaver == null || !File.Exists(fileSaver.GetSavePath(item)))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                // Manual edit did not occur
                                // Since local metadata saving is disabled, consider it disabled
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (!libraryOptions.MetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error in {0}.IsEnabledFor", saver.Name);
                return(false);
            }
        }