From b23bdfe9f21aeb48ec83c20166cbc1132162362f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 24 Dec 2016 02:41:53 -0500 Subject: [PATCH] add content type error handling --- .../Data/SqliteItemRepository.cs | 10 +++++++++- Emby.Server.Implementations/Library/LibraryManager.cs | 6 +++++- MediaBrowser.Api/ItemUpdateService.cs | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 8e6a277a47..8c16216b95 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -5267,11 +5267,19 @@ namespace Emby.Server.Implementations.Data { foreach (var pair in values) { + var itemValue = pair.Item2; + + // Don't save if invalid + if (string.IsNullOrWhiteSpace(itemValue)) + { + continue; + } + statement.Reset(); statement.TryBind("@ItemId", itemId.ToGuidParamValue()); statement.TryBind("@Type", pair.Item1); - statement.TryBind("@Value", pair.Item2); + statement.TryBind("@Value", itemValue); if (pair.Item2 == null) { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 5bf53fcb43..4c788a2abe 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -3084,7 +3084,11 @@ namespace Emby.Server.Implementations.Library foreach (var contentType in ConfigurationManager.Configuration.ContentTypes) { - if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase) + if (string.IsNullOrWhiteSpace(contentType.Name)) + { + removeList.Add(contentType); + } + else if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(path, contentType.Name)) { removeList.Add(contentType); diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index b0a0e79aee..5c99d98c25 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -99,6 +99,7 @@ namespace MediaBrowser.Api var path = item.ContainingFolderPath; var types = _config.Configuration.ContentTypes + .Where(i => !string.IsNullOrWhiteSpace(i.Name)) .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase)) .ToList();