mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	cleanup content overrides when adding library paths
This commit is contained in:
		
							parent
							
								
									ff3f6661ec
								
							
						
					
					
						commit
						35e83dc73d
					
				@ -70,26 +70,21 @@ namespace MediaBrowser.Api
 | 
				
			|||||||
                Cultures = _localizationManager.GetCultures().ToList()
 | 
					                Cultures = _localizationManager.GetCultures().ToList()
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var locationType = item.LocationType;
 | 
					            if (!item.IsVirtualItem && !(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
 | 
				
			||||||
            if (locationType == LocationType.FileSystem ||
 | 
					 | 
				
			||||||
                locationType == LocationType.Offline)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
 | 
					                var inheritedContentType = _libraryManager.GetInheritedContentType(item);
 | 
				
			||||||
 | 
					                var configuredContentType = _libraryManager.GetConfiguredContentType(item);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var inheritedContentType = _libraryManager.GetInheritedContentType(item);
 | 
					                    info.ContentTypeOptions = GetContentTypeOptions(true);
 | 
				
			||||||
                    var configuredContentType = _libraryManager.GetConfiguredContentType(item);
 | 
					                    info.ContentType = configuredContentType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
 | 
					                    if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        info.ContentTypeOptions = GetContentTypeOptions(true);
 | 
					                        info.ContentTypeOptions = info.ContentTypeOptions
 | 
				
			||||||
                        info.ContentType = configuredContentType;
 | 
					                            .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
 | 
				
			||||||
 | 
					                            .ToList();
 | 
				
			||||||
                        if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            info.ContentTypeOptions = info.ContentTypeOptions
 | 
					 | 
				
			||||||
                                .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
 | 
					 | 
				
			||||||
                                .ToList();
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -2791,6 +2791,31 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            _fileSystem.CreateShortcut(lnk, path);
 | 
					            _fileSystem.CreateShortcut(lnk, path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            RemoveContentTypeOverrides(path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void RemoveContentTypeOverrides(string path)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var removeList = new List<NameValuePair>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (var contentType in ConfigurationManager.Configuration.ContentTypes)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase)
 | 
				
			||||||
 | 
					                    || _fileSystem.ContainsSubPath(path, contentType.Name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    removeList.Add(contentType);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (removeList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ConfigurationManager.Configuration.ContentTypes = ConfigurationManager.Configuration.ContentTypes
 | 
				
			||||||
 | 
					                    .Except(removeList)
 | 
				
			||||||
 | 
					                        .ToArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                ConfigurationManager.SaveConfiguration();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void RemoveMediaPath(string virtualFolderName, string mediaPath)
 | 
					        public void RemoveMediaPath(string virtualFolderName, string mediaPath)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user