Fixed a file system issue and also added a few more performance tweaks

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti
2012-08-20 21:51:00 -04:00
parent 906ad3cb1a
commit e6a95defc9
11 changed files with 64 additions and 64 deletions

View File

@@ -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<string, WIN32_FIND_DATA>? GetFileSystemEntry(string path, bool? isFolder)
{
foreach (KeyValuePair<string, WIN32_FIND_DATA> entry in FileSystemChildren)
for (int i = 0; i < FileSystemChildren.Length; i++)
{
KeyValuePair<string, WIN32_FIND_DATA> 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<string, WIN32_FIND_DATA>? GetFileSystemEntryByName(string name, bool? isFolder)
{
foreach (KeyValuePair<string, WIN32_FIND_DATA> entry in FileSystemChildren)
for (int i = 0; i < FileSystemChildren.Length; i++)
{
KeyValuePair<string, WIN32_FIND_DATA> 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;
}

View File

@@ -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
/// </summary>
private void PopulateImages(BaseEntity item, ItemResolveEventArgs args)
{
foreach (KeyValuePair<string, WIN32_FIND_DATA> 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<string> backdropFiles = new List<string>();
foreach (KeyValuePair<string, WIN32_FIND_DATA> 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;
}

View File

@@ -32,8 +32,10 @@ namespace MediaBrowser.Controller.Providers
List<Video> localTrailers = new List<Video>();
foreach (string file in allFiles)
for (int i = 0; i < allFiles.Length; i++)
{
string file = allFiles[i];
BaseItem child = await Kernel.Instance.ItemController.GetItem(file).ConfigureAwait(false);
Video video = child as Video;

View File

@@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition;
using System.IO;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Resolvers
@@ -51,8 +49,10 @@ namespace MediaBrowser.Controller.Resolvers
}
// Also check the subfolders for bluray or dvd
foreach (KeyValuePair<string, WIN32_FIND_DATA> folder in args.FileSystemChildren)
for (int i = 0; i < args.FileSystemChildren.Length; i++)
{
var folder = args.FileSystemChildren[i];
if (!folder.Value.IsDirectory)
{
continue;