I lied - re-worked metadata folder handling again. Should now really only hit once and is available for other item types

This commit is contained in:
ebr11 Eric Reed spam 2012-09-19 10:22:53 -04:00
parent 442081f4e2
commit 6edc836ce5
6 changed files with 26 additions and 18 deletions

View File

@ -7,7 +7,13 @@ namespace MediaBrowser.Controller.Entities.TV
/// <summary>
/// Store these to reduce disk access in Episode Resolver
/// </summary>
public string[] MetadataFiles { get; set; }
public string[] MetadataFiles
{
get
{
return ResolveArgs.MetadataFiles ?? new string[] { };
}
}
/// <summary>
/// Determines if the metafolder contains a given file

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Controller.Library;
@ -67,6 +68,12 @@ namespace MediaBrowser.Controller.IO
args.IsBDFolder |= file.cFileName.Equals("bdmv", StringComparison.OrdinalIgnoreCase);
args.IsDVDFolder |= file.cFileName.Equals("video_ts", StringComparison.OrdinalIgnoreCase);
args.IsHDDVDFolder |= file.cFileName.Equals("hvdvd_ts", StringComparison.OrdinalIgnoreCase);
//and check to see if it is a metadata folder and collect contents now if so
if (IsMetadataFolder(file.cFileName))
{
args.MetadataFiles = Directory.GetFiles(Path.Combine(args.Path, "metadata"), "*", SearchOption.TopDirectoryOnly);
}
}
}
}
@ -83,6 +90,11 @@ namespace MediaBrowser.Controller.IO
return args;
}
public static bool IsMetadataFolder(string path)
{
return path.TrimEnd('\\').EndsWith("metadata", StringComparison.OrdinalIgnoreCase);
}
public static bool IsVideoFile(string path)
{
string extension = System.IO.Path.GetExtension(path).ToLower();

View File

@ -39,13 +39,10 @@ namespace MediaBrowser.Controller.Library
public bool IsDVDFolder { get; set; }
public bool IsHDDVDFolder { get; set; }
public bool IsMetadataFolder
{
get
{
return this.FileInfo.cFileName.Equals("metadata", StringComparison.OrdinalIgnoreCase);
}
}
/// <summary>
/// Store these to reduce disk access in Resolvers
/// </summary>
public string[] MetadataFiles { get; set; }
public WIN32_FIND_DATA? GetFileSystemEntry(string path)
{

View File

@ -18,6 +18,7 @@ namespace MediaBrowser.Controller.Resolvers
public static List<string> IgnoreFolders = new List<string>()
{
"trailers",
"metadata",
"bdmv",
"certificate",
"backup",
@ -62,11 +63,6 @@ namespace MediaBrowser.Controller.Resolvers
// Ignore any folders containing a file called .ignore
resolve = false;
}
else if (args.IsMetadataFolder)
{
// I think this is redundant, but...
resolve = false;
}
return resolve;
}

View File

@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Resolvers
protected override Folder Resolve(ItemResolveEventArgs args)
{
if (args.IsDirectory && !args.IsMetadataFolder)
if (args.IsDirectory)
{
return new Folder() { PhysicalLocations = args.PhysicalLocations };
}

View File

@ -10,15 +10,12 @@ namespace MediaBrowser.Controller.Resolvers.TV
{
protected override Season Resolve(ItemResolveEventArgs args)
{
if (args.Parent is Series && args.IsDirectory && !args.IsMetadataFolder)
if (args.Parent is Series && args.IsDirectory)
{
var season = new Season { };
season.IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path);
// Gather these now so that the episode provider classes can utilize them instead of having to make their own file system calls
season.MetadataFiles = args.ContainsFolder("metadata") ? Directory.GetFiles(Path.Combine(args.Path, "metadata"), "*", SearchOption.TopDirectoryOnly) : new string[] { };
return season;
}