From 6cf28f1c4e191b8599aedc1f71c01de77d7ff7cb Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 5 Aug 2016 02:36:04 +0200 Subject: [PATCH] Fix IndexOutOfRangeException Fixes situations where the filename is something like "-------". --- .../Library/LibraryManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 015fc3778f..7af495f5a0 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -923,14 +923,14 @@ namespace MediaBrowser.Server.Implementations.Library if (type == typeof(Person)) { - var subFolderIndex = 0; - - while (!char.IsLetterOrDigit(validFilename[subFolderIndex])) + foreach (char c in validFilename) { - subFolderIndex++; + if (char.IsLetterOrDigit(c)) + { + subFolderPrefix = c.ToString(); + break; + } } - - subFolderPrefix = validFilename.Substring(subFolderIndex, 1); } var fullPath = string.IsNullOrEmpty(subFolderPrefix) ?