diff --git a/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs b/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs index 5efdfdb70..ecb164455 100644 --- a/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs +++ b/MediaBrowser.Controller/Events/ItemResolveEventArgs.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.IO; -using MediaBrowser.Model.Entities; using MediaBrowser.Controller.IO; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Events { @@ -15,15 +15,17 @@ namespace MediaBrowser.Controller.Events public KeyValuePair? GetFileSystemEntry(string path, bool? isFolder) { - foreach (KeyValuePair entry in FileSystemChildren) + for (int i = 0; i < FileSystemChildren.Length; i++) { + KeyValuePair entry = FileSystemChildren[i]; + if (isFolder.HasValue) { - if (isFolder.Value && entry.Value.IsDirectory) + if (isFolder.Value && !entry.Value.IsDirectory) { continue; } - else if (!isFolder.Value && !entry.Value.IsDirectory) + else if (!isFolder.Value && entry.Value.IsDirectory) { continue; } @@ -40,15 +42,17 @@ namespace MediaBrowser.Controller.Events public KeyValuePair? GetFileSystemEntryByName(string name, bool? isFolder) { - foreach (KeyValuePair entry in FileSystemChildren) + for (int i = 0; i < FileSystemChildren.Length; i++) { + KeyValuePair entry = FileSystemChildren[i]; + if (isFolder.HasValue) { - if (isFolder.Value && entry.Value.IsDirectory) + if (isFolder.Value && !entry.Value.IsDirectory) { continue; } - else if (!isFolder.Value && !entry.Value.IsDirectory) + else if (!isFolder.Value && entry.Value.IsDirectory) { continue; } diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs index d005b50ff..7785a558a 100644 --- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs +++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using System.ComponentModel.Composition; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.Events; using MediaBrowser.Model.Entities; -using MediaBrowser.Controller.IO; namespace MediaBrowser.Controller.Providers { @@ -48,8 +46,10 @@ namespace MediaBrowser.Controller.Providers /// private void PopulateImages(BaseEntity item, ItemResolveEventArgs args) { - foreach (KeyValuePair file in args.FileSystemChildren) + for (int i = 0; i < args.FileSystemChildren.Length; i++) { + var file = args.FileSystemChildren[i]; + if (file.Value.IsDirectory) { continue; @@ -81,8 +81,10 @@ namespace MediaBrowser.Controller.Providers { List backdropFiles = new List(); - foreach (KeyValuePair file in args.FileSystemChildren) + for (int i = 0; i < args.FileSystemChildren.Length; i++) { + var file = args.FileSystemChildren[i]; + if (file.Value.IsDirectory) { continue; @@ -126,7 +128,7 @@ namespace MediaBrowser.Controller.Providers } } - if (backdropFiles.Any()) + if (backdropFiles.Count > 0) { item.BackdropImagePaths = backdropFiles; } diff --git a/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs b/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs index e7e0bd828..2476df7cd 100644 --- a/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs +++ b/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs @@ -32,8 +32,10 @@ namespace MediaBrowser.Controller.Providers List