From e6a95defc9c6dd34b25ca80dab920e8619d3e34d Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Mon, 20 Aug 2012 21:51:00 -0400 Subject: [PATCH] Fixed a file system issue and also added a few more performance tweaks --- .../Events/ItemResolveEventArgs.cs | 18 ++++++++------ .../ImageFromMediaLocationProvider.cs | 12 ++++++---- .../Providers/LocalTrailerProvider.cs | 4 +++- .../Resolvers/VideoResolver.cs | 8 +++---- .../Resolvers/MovieResolver.cs | 10 +++----- MediaBrowser.TV/Entities/Season.cs | 21 +++++++++++++--- .../EpisodeImageFromMediaLocationProvider.cs | 2 +- .../Providers/EpisodeProviderFromXml.cs | 24 ++++++++++--------- MediaBrowser.TV/Resolvers/SeasonResolver.cs | 1 - MediaBrowser.TV/Resolvers/SeriesResolver.cs | 6 ----- MediaBrowser.TV/TVUtils.cs | 22 ++++------------- 11 files changed, 64 insertions(+), 64 deletions(-) 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