fixes #200 - MB3 Locking Folders for a long time

pull/702/head
Luke Pulverenti 12 years ago
parent 90bb3d46c4
commit b443d591a2

@ -205,7 +205,7 @@ namespace MediaBrowser.Api
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns> /// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request) private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request)
{ {
var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly).Where(i => var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos().Where(i =>
{ {
if (i.Attributes.HasFlag(FileAttributes.System)) if (i.Attributes.HasFlag(FileAttributes.System))
{ {

@ -200,7 +200,7 @@ namespace MediaBrowser.Api.Playback.Hls
var directory = Path.GetDirectoryName(outputFilePath); var directory = Path.GetDirectoryName(outputFilePath);
var name = Path.GetFileNameWithoutExtension(outputFilePath); var name = Path.GetFileNameWithoutExtension(outputFilePath);
var filesToDelete = Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly) var filesToDelete = Directory.EnumerateFiles(directory)
.Where(f => f.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1) .Where(f => f.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1)
.ToList(); .ToList();

@ -428,7 +428,7 @@ namespace MediaBrowser.Controller.Drawing
var metaFileEntry = item.ResolveArgs.GetMetaFileByPath(imagePath); var metaFileEntry = item.ResolveArgs.GetMetaFileByPath(imagePath);
// If we didn't the metafile entry, check the Season // If we didn't the metafile entry, check the Season
if (!metaFileEntry.HasValue) if (metaFileEntry == null)
{ {
var episode = item as Episode; var episode = item as Episode;
@ -439,7 +439,7 @@ namespace MediaBrowser.Controller.Drawing
} }
// See if we can avoid a file system lookup by looking for the file in ResolveArgs // See if we can avoid a file system lookup by looking for the file in ResolveArgs
return metaFileEntry == null ? File.GetLastWriteTimeUtc(imagePath) : metaFileEntry.Value.LastWriteTimeUtc; return metaFileEntry == null ? File.GetLastWriteTimeUtc(imagePath) : metaFileEntry.LastWriteTimeUtc;
} }
/// <summary> /// <summary>

@ -212,7 +212,7 @@ namespace MediaBrowser.Controller.Dto
var metaFileEntry = item.ResolveArgs.GetMetaFileByPath(path); var metaFileEntry = item.ResolveArgs.GetMetaFileByPath(path);
// See if we can avoid a file system lookup by looking for the file in ResolveArgs // See if we can avoid a file system lookup by looking for the file in ResolveArgs
var dateModified = metaFileEntry == null ? File.GetLastWriteTimeUtc(path) : metaFileEntry.Value.LastWriteTimeUtc; var dateModified = metaFileEntry == null ? File.GetLastWriteTimeUtc(path) : metaFileEntry.LastWriteTimeUtc;
ImageSize size; ImageSize size;

@ -244,13 +244,13 @@ namespace MediaBrowser.Controller.Entities
// Record the name of each file // Record the name of each file
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order // Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
foreach (var file in ResolveArgs.FileSystemChildren.OrderBy(f => f.cFileName)) foreach (var file in ResolveArgs.FileSystemChildren.OrderBy(f => f.Name))
{ {
sb.Append(file.cFileName); sb.Append(file.Name);
} }
foreach (var file in ResolveArgs.MetadataFiles.OrderBy(f => f.cFileName)) foreach (var file in ResolveArgs.MetadataFiles.OrderBy(f => f.Name))
{ {
sb.Append(file.cFileName); sb.Append(file.Name);
} }
return sb.ToString().GetMD5(); return sb.ToString().GetMD5();
@ -307,7 +307,7 @@ namespace MediaBrowser.Controller.Entities
/// Resets the resolve args. /// Resets the resolve args.
/// </summary> /// </summary>
/// <param name="pathInfo">The path info.</param> /// <param name="pathInfo">The path info.</param>
public void ResetResolveArgs(WIN32_FIND_DATA? pathInfo) public void ResetResolveArgs(FileSystemInfo pathInfo)
{ {
ResolveArgs = CreateResolveArgs(pathInfo); ResolveArgs = CreateResolveArgs(pathInfo);
} }
@ -318,17 +318,14 @@ namespace MediaBrowser.Controller.Entities
/// <param name="pathInfo">The path info.</param> /// <param name="pathInfo">The path info.</param>
/// <returns>ItemResolveArgs.</returns> /// <returns>ItemResolveArgs.</returns>
/// <exception cref="System.IO.IOException">Unable to retrieve file system info for + path</exception> /// <exception cref="System.IO.IOException">Unable to retrieve file system info for + path</exception>
protected internal virtual ItemResolveArgs CreateResolveArgs(WIN32_FIND_DATA? pathInfo = null) protected internal virtual ItemResolveArgs CreateResolveArgs(FileSystemInfo pathInfo = null)
{ {
var path = Path; var path = Path;
// non file-system entries will not have a path // non file-system entries will not have a path
if (LocationType != LocationType.FileSystem || string.IsNullOrEmpty(path)) if (LocationType != LocationType.FileSystem || string.IsNullOrEmpty(path))
{ {
return new ItemResolveArgs(ConfigurationManager.ApplicationPaths) return new ItemResolveArgs(ConfigurationManager.ApplicationPaths);
{
FileInfo = new WIN32_FIND_DATA()
};
} }
if (UseParentPathToCreateResolveArgs) if (UseParentPathToCreateResolveArgs)
@ -336,16 +333,16 @@ namespace MediaBrowser.Controller.Entities
path = System.IO.Path.GetDirectoryName(path); path = System.IO.Path.GetDirectoryName(path);
} }
pathInfo = pathInfo ?? FileSystem.GetFileData(path); pathInfo = pathInfo ?? FileSystem.GetFileSystemInfo(path);
if (!pathInfo.HasValue) if (pathInfo == null || !pathInfo.Exists)
{ {
throw new IOException("Unable to retrieve file system info for " + path); throw new IOException("Unable to retrieve file system info for " + path);
} }
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths) var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
{ {
FileInfo = pathInfo.Value, FileInfo = pathInfo,
Path = path, Path = path,
Parent = Parent Parent = Parent
}; };
@ -735,11 +732,11 @@ namespace MediaBrowser.Controller.Entities
return new List<Trailer>(); return new List<Trailer>();
} }
IEnumerable<WIN32_FIND_DATA> files; IEnumerable<FileSystemInfo> files;
try try
{ {
files = FileSystem.GetFiles(folder.Value.Path); files = new DirectoryInfo(folder.FullName).EnumerateFiles();
} }
catch (IOException ex) catch (IOException ex)
{ {
@ -793,11 +790,11 @@ namespace MediaBrowser.Controller.Entities
return new List<Audio.Audio>(); return new List<Audio.Audio>();
} }
IEnumerable<WIN32_FIND_DATA> files; IEnumerable<FileSystemInfo> files;
try try
{ {
files = FileSystem.GetFiles(folder.Value.Path); files = new DirectoryInfo(folder.FullName).EnumerateFiles();
} }
catch (IOException ex) catch (IOException ex)
{ {

@ -768,7 +768,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>IEnumerable{BaseItem}.</returns> /// <returns>IEnumerable{BaseItem}.</returns>
protected virtual IEnumerable<BaseItem> GetNonCachedChildren() protected virtual IEnumerable<BaseItem> GetNonCachedChildren()
{ {
IEnumerable<WIN32_FIND_DATA> fileSystemChildren; IEnumerable<FileSystemInfo> fileSystemChildren;
try try
{ {

@ -115,7 +115,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <returns>IEnumerable{Video}.</returns> /// <returns>IEnumerable{Video}.</returns>
private IEnumerable<Video> LoadSpecialFeatures() private IEnumerable<Video> LoadSpecialFeatures()
{ {
WIN32_FIND_DATA? folder; FileSystemInfo folder;
try try
{ {
@ -133,11 +133,11 @@ namespace MediaBrowser.Controller.Entities.Movies
return new List<Video>(); return new List<Video>();
} }
IEnumerable<WIN32_FIND_DATA> files; IEnumerable<FileSystemInfo> files;
try try
{ {
files = FileSystem.GetFiles(folder.Value.Path); files = new DirectoryInfo(folder.FullName).EnumerateFiles();
} }
catch (IOException ex) catch (IOException ex)
{ {

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.IO; using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -134,9 +135,9 @@ namespace MediaBrowser.Controller.Entities.TV
{ {
var folder = args.GetFileSystemEntryByName("metadata"); var folder = args.GetFileSystemEntryByName("metadata");
if (folder.HasValue) if (folder != null)
{ {
args.AddMetadataFiles(FileSystem.GetFiles(folder.Value.Path)); args.AddMetadataFiles(new DirectoryInfo(folder.FullName).EnumerateFiles());
} }
} }
@ -145,7 +146,7 @@ namespace MediaBrowser.Controller.Entities.TV
/// </summary> /// </summary>
/// <param name="pathInfo">The path info.</param> /// <param name="pathInfo">The path info.</param>
/// <returns>ItemResolveArgs.</returns> /// <returns>ItemResolveArgs.</returns>
protected internal override ItemResolveArgs CreateResolveArgs(WIN32_FIND_DATA? pathInfo = null) protected internal override ItemResolveArgs CreateResolveArgs(FileSystemInfo pathInfo = null)
{ {
var args = base.CreateResolveArgs(pathInfo); var args = base.CreateResolveArgs(pathInfo);

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions; using System.IO;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.IO; using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Localization;
@ -68,7 +69,7 @@ namespace MediaBrowser.Controller.Entities.TV
/// </summary> /// </summary>
/// <param name="pathInfo">The path info.</param> /// <param name="pathInfo">The path info.</param>
/// <returns>ItemResolveArgs.</returns> /// <returns>ItemResolveArgs.</returns>
protected internal override ItemResolveArgs CreateResolveArgs(WIN32_FIND_DATA? pathInfo = null) protected internal override ItemResolveArgs CreateResolveArgs(FileSystemInfo pathInfo = null)
{ {
var args = base.CreateResolveArgs(pathInfo); var args = base.CreateResolveArgs(pathInfo);

@ -3,7 +3,7 @@ using MediaBrowser.Model.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Linq;
namespace MediaBrowser.Controller.IO namespace MediaBrowser.Controller.IO
{ {
@ -13,91 +13,47 @@ namespace MediaBrowser.Controller.IO
public static class FileData public static class FileData
{ {
/// <summary> /// <summary>
/// Gets all file system entries within a foler /// Gets the filtered file system entries.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="searchPattern">The search pattern.</param> /// <param name="searchPattern">The search pattern.</param>
/// <param name="includeFiles">if set to <c>true</c> [include files].</param>
/// <param name="includeDirectories">if set to <c>true</c> [include directories].</param>
/// <param name="flattenFolderDepth">The flatten folder depth.</param> /// <param name="flattenFolderDepth">The flatten folder depth.</param>
/// <param name="resolveShortcuts">if set to <c>true</c> [resolve shortcuts].</param> /// <param name="resolveShortcuts">if set to <c>true</c> [resolve shortcuts].</param>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns>Dictionary{System.StringWIN32_FIND_DATA}.</returns> /// <returns>Dictionary{System.StringFileSystemInfo}.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="System.IO.IOException">GetFileSystemEntries failed</exception> public static Dictionary<string, FileSystemInfo> GetFilteredFileSystemEntries(string path, ILogger logger, string searchPattern = "*", int flattenFolderDepth = 0, bool resolveShortcuts = true, ItemResolveArgs args = null)
public static Dictionary<string, WIN32_FIND_DATA> GetFilteredFileSystemEntries(string path, ILogger logger, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true, int flattenFolderDepth = 0, bool resolveShortcuts = true, ItemResolveArgs args = null)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
throw new ArgumentNullException(); throw new ArgumentNullException("path");
} }
var lpFileName = Path.Combine(path, searchPattern); var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly)
.Where(i => !i.Attributes.HasFlag(FileAttributes.System) && !i.Name.Equals(".") && !i.Name.Equals(".."));
WIN32_FIND_DATA lpFindFileData; foreach (var entry in entries)
var handle = NativeMethods.FindFirstFileEx(lpFileName, FINDEX_INFO_LEVELS.FindExInfoBasic, out lpFindFileData,
FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.FIND_FIRST_EX_LARGE_FETCH);
if (handle == IntPtr.Zero)
{
int hr = Marshal.GetLastWin32Error();
if (hr != 2 && hr != 0x12)
{
throw new IOException("GetFileSystemEntries failed");
}
return new Dictionary<string, WIN32_FIND_DATA>(StringComparer.OrdinalIgnoreCase);
}
var dict = new Dictionary<string, WIN32_FIND_DATA>(StringComparer.OrdinalIgnoreCase);
if (FileSystem.IncludeInFindFileOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories))
{ {
if (!string.IsNullOrEmpty(lpFindFileData.cFileName)) var isDirectory = entry.Attributes.HasFlag(FileAttributes.Directory);
{
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName);
dict[lpFindFileData.Path] = lpFindFileData;
}
}
while (NativeMethods.FindNextFile(handle, out lpFindFileData) != IntPtr.Zero) if (resolveShortcuts && FileSystem.IsShortcut(entry.FullName))
{
// This is the one circumstance where we can completely disregard a file
if (lpFindFileData.IsSystemFile)
{ {
continue; var newPath = FileSystem.ResolveShortcut(entry.FullName);
}
// Filter out invalid entries
if (lpFindFileData.cFileName.Equals(".", StringComparison.OrdinalIgnoreCase))
{
continue;
}
if (lpFindFileData.cFileName.Equals("..", StringComparison.OrdinalIgnoreCase))
{
continue;
}
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName);
if (resolveShortcuts && FileSystem.IsShortcut(lpFindFileData.Path))
{
var newPath = FileSystem.ResolveShortcut(lpFindFileData.Path);
if (string.IsNullOrWhiteSpace(newPath)) if (string.IsNullOrWhiteSpace(newPath))
{ {
//invalid shortcut - could be old or target could just be unavailable //invalid shortcut - could be old or target could just be unavailable
logger.Warn("Encountered invalid shortuct: " + lpFindFileData.Path); logger.Warn("Encountered invalid shortuct: " + entry.FullName);
continue; continue;
} }
var data = FileSystem.GetFileData(newPath); var data = FileSystem.GetFileSystemInfo(newPath);
if (data.HasValue) if (data.Exists)
{ {
lpFindFileData = data.Value;
// Find out if the shortcut is pointing to a directory or file // Find out if the shortcut is pointing to a directory or file
if (lpFindFileData.IsDirectory) if (data.Attributes.HasFlag(FileAttributes.Directory))
{ {
// add to our physical locations // add to our physical locations
if (args != null) if (args != null)
@ -106,25 +62,25 @@ namespace MediaBrowser.Controller.IO
} }
} }
dict[lpFindFileData.Path] = lpFindFileData; dict[data.FullName] = data;
} }
} }
else if (flattenFolderDepth > 0 && lpFindFileData.IsDirectory) else if (flattenFolderDepth > 0 && isDirectory)
{ {
foreach (var child in GetFilteredFileSystemEntries(lpFindFileData.Path, logger, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) foreach (var child in GetFilteredFileSystemEntries(entry.FullName, logger, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts))
{ {
dict[child.Key] = child.Value; dict[child.Key] = child.Value;
} }
} }
else else
{ {
dict[lpFindFileData.Path] = lpFindFileData; dict[entry.FullName] = entry;
} }
} }
NativeMethods.FindClose(handle);
return dict; return dict;
} }
} }
} }

@ -1,8 +1,7 @@
using System; using MediaBrowser.Model.Logging;
using System.Collections.Generic; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace MediaBrowser.Controller.IO namespace MediaBrowser.Controller.IO
@ -13,153 +12,77 @@ namespace MediaBrowser.Controller.IO
public static class FileSystem public static class FileSystem
{ {
/// <summary> /// <summary>
/// Gets information about a path /// Gets the file system info.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="System.ArgumentNullException">path</exception> public static FileSystemInfo GetFileSystemInfo(string path)
/// <exception cref="System.IO.IOException">GetFileData failed for + path</exception>
public static WIN32_FIND_DATA? GetFileData(string path)
{ {
if (string.IsNullOrEmpty(path)) // Take a guess to try and avoid two file system hits, but we'll double-check by calling Exists
if (Path.HasExtension(path))
{ {
throw new ArgumentNullException("path"); var fileInfo = new FileInfo(path);
}
WIN32_FIND_DATA data;
var handle = NativeMethods.FindFirstFileEx(path, FINDEX_INFO_LEVELS.FindExInfoBasic, out data,
FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.NONE);
var getFilename = false; if (fileInfo.Exists)
if (handle == NativeMethods.INVALID_HANDLE_VALUE && !Path.HasExtension(path))
{
if (!path.EndsWith("*", StringComparison.OrdinalIgnoreCase))
{ {
NativeMethods.FindClose(handle); return fileInfo;
handle = NativeMethods.FindFirstFileEx(Path.Combine(path, "*"), FINDEX_INFO_LEVELS.FindExInfoBasic, out data,
FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.NONE);
getFilename = true;
} }
}
if (handle == IntPtr.Zero)
{
throw new IOException("GetFileData failed for " + path);
}
NativeMethods.FindClose(handle); return new DirectoryInfo(path);
// According to MSDN documentation, this will default to 1601 for paths that don't exist.
if (data.CreationTimeUtc.Year == 1601)
{
return null;
} }
else
if (getFilename)
{ {
data.cFileName = Path.GetFileName(path); var fileInfo = new DirectoryInfo(path);
}
data.Path = path; if (fileInfo.Exists)
return data; {
} return fileInfo;
}
/// <summary> return new FileInfo(path);
/// Gets all files within a folder }
/// </summary>
/// <param name="path">The path.</param>
/// <param name="searchPattern">The search pattern.</param>
/// <returns>IEnumerable{WIN32_FIND_DATA}.</returns>
public static IEnumerable<WIN32_FIND_DATA> GetFiles(string path, string searchPattern = "*")
{
return GetFileSystemEntries(path, searchPattern, includeDirectories: false);
} }
/// <summary> /// <summary>
/// Gets all file system entries within a foler /// Gets the creation time UTC.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="info">The info.</param>
/// <param name="searchPattern">The search pattern.</param> /// <param name="logger">The logger.</param>
/// <param name="includeFiles">if set to <c>true</c> [include files].</param> /// <returns>DateTime.</returns>
/// <param name="includeDirectories">if set to <c>true</c> [include directories].</param> public static DateTime GetLastWriteTimeUtc(FileSystemInfo info, ILogger logger)
/// <returns>IEnumerable{WIN32_FIND_DATA}.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="System.IO.IOException">GetFileSystemEntries failed</exception>
public static IEnumerable<WIN32_FIND_DATA> GetFileSystemEntries(string path, string searchPattern = "*", bool includeFiles = true, bool includeDirectories = true)
{ {
if (string.IsNullOrEmpty(path)) // This could throw an error on some file systems that have dates out of range
{
throw new ArgumentNullException("path");
}
var lpFileName = Path.Combine(path, searchPattern);
WIN32_FIND_DATA lpFindFileData;
var handle = NativeMethods.FindFirstFileEx(lpFileName, FINDEX_INFO_LEVELS.FindExInfoBasic, out lpFindFileData,
FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, FindFirstFileExFlags.FIND_FIRST_EX_LARGE_FETCH);
if (handle == IntPtr.Zero)
{
var hr = Marshal.GetLastWin32Error();
if (hr != 2 && hr != 0x12)
{
throw new IOException("GetFileSystemEntries failed");
}
yield break;
}
if (IncludeInFindFileOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories)) try
{ {
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName); return info.LastAccessTimeUtc;
yield return lpFindFileData;
} }
catch (Exception ex)
while (NativeMethods.FindNextFile(handle, out lpFindFileData) != IntPtr.Zero)
{ {
if (IncludeInFindFileOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories)) logger.ErrorException("Error determining LastAccessTimeUtc for {0}", ex, info.FullName);
{ return DateTime.MinValue;
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName);
yield return lpFindFileData;
}
} }
NativeMethods.FindClose(handle);
} }
/// <summary> /// <summary>
/// Includes the in find file output. /// Gets the creation time UTC.
/// </summary> /// </summary>
/// <param name="cFileName">Name of the c file.</param> /// <param name="info">The info.</param>
/// <param name="attributes">The attributes.</param> /// <param name="logger">The logger.</param>
/// <param name="includeFiles">if set to <c>true</c> [include files].</param> /// <returns>DateTime.</returns>
/// <param name="includeDirectories">if set to <c>true</c> [include directories].</param> public static DateTime GetCreationTimeUtc(FileSystemInfo info, ILogger logger)
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public static bool IncludeInFindFileOutput(string cFileName, FileAttributes attributes, bool includeFiles, bool includeDirectories)
{ {
if (cFileName.Equals(".", StringComparison.OrdinalIgnoreCase)) // This could throw an error on some file systems that have dates out of range
{
return false;
}
if (cFileName.Equals("..", StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (!includeFiles && !attributes.HasFlag(FileAttributes.Directory)) try
{ {
return false; return info.CreationTimeUtc;
} }
catch (Exception ex)
if (!includeDirectories && attributes.HasFlag(FileAttributes.Directory))
{ {
return false; logger.ErrorException("Error determining CreationTimeUtc for {0}", ex, info.FullName);
return DateTime.MinValue;
} }
return true;
} }
/// <summary> /// <summary>

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities; using System.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.IO; using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Resolvers;
@ -40,7 +41,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="fileInfo">The file info.</param> /// <param name="fileInfo">The file info.</param>
/// <returns>BaseItem.</returns> /// <returns>BaseItem.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
BaseItem ResolvePath(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null); BaseItem ResolvePath(string path, Folder parent = null, FileSystemInfo fileInfo = null);
/// <summary> /// <summary>
/// Resolves a set of files into a list of BaseItem /// Resolves a set of files into a list of BaseItem
@ -49,7 +50,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="files">The files.</param> /// <param name="files">The files.</param>
/// <param name="parent">The parent.</param> /// <param name="parent">The parent.</param>
/// <returns>List{``0}.</returns> /// <returns>List{``0}.</returns>
List<T> ResolvePaths<T>(IEnumerable<WIN32_FIND_DATA> files, Folder parent) List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, Folder parent)
where T : BaseItem; where T : BaseItem;
/// <summary> /// <summary>

@ -31,7 +31,7 @@ namespace MediaBrowser.Controller.Library
/// Gets the file system children. /// Gets the file system children.
/// </summary> /// </summary>
/// <value>The file system children.</value> /// <value>The file system children.</value>
public IEnumerable<WIN32_FIND_DATA> FileSystemChildren public IEnumerable<FileSystemInfo> FileSystemChildren
{ {
get { return FileSystemDictionary.Values; } get { return FileSystemDictionary.Values; }
} }
@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Library
/// Gets or sets the file system dictionary. /// Gets or sets the file system dictionary.
/// </summary> /// </summary>
/// <value>The file system dictionary.</value> /// <value>The file system dictionary.</value>
public Dictionary<string, WIN32_FIND_DATA> FileSystemDictionary { get; set; } public Dictionary<string, FileSystemInfo> FileSystemDictionary { get; set; }
/// <summary> /// <summary>
/// Gets or sets the parent. /// Gets or sets the parent.
@ -52,7 +52,7 @@ namespace MediaBrowser.Controller.Library
/// Gets or sets the file info. /// Gets or sets the file info.
/// </summary> /// </summary>
/// <value>The file info.</value> /// <value>The file info.</value>
public WIN32_FIND_DATA FileInfo { get; set; } public FileSystemInfo FileInfo { get; set; }
/// <summary> /// <summary>
/// Gets or sets the path. /// Gets or sets the path.
@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Library
{ {
get get
{ {
return FileInfo.dwFileAttributes.HasFlag(FileAttributes.Directory); return FileInfo.Attributes.HasFlag(FileAttributes.Directory);
} }
} }
@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Library
{ {
get get
{ {
return FileInfo.IsHidden; return FileInfo.Attributes.HasFlag(FileAttributes.Hidden);
} }
} }
@ -92,7 +92,7 @@ namespace MediaBrowser.Controller.Library
{ {
get get
{ {
return FileInfo.IsSystemFile; return FileInfo.Attributes.HasFlag(FileAttributes.System);
} }
} }
@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.Library
return false; return false;
} }
var parentDir = FileInfo.Path != null ? System.IO.Path.GetDirectoryName(FileInfo.Path) ?? string.Empty : string.Empty; var parentDir = System.IO.Path.GetDirectoryName(FileInfo.FullName) ?? string.Empty;
return (parentDir.Length > _appPaths.RootFolderPath.Length return (parentDir.Length > _appPaths.RootFolderPath.Length
&& parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase)); && parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase));
@ -187,13 +187,13 @@ namespace MediaBrowser.Controller.Library
/// Store these to reduce disk access in Resolvers /// Store these to reduce disk access in Resolvers
/// </summary> /// </summary>
/// <value>The metadata file dictionary.</value> /// <value>The metadata file dictionary.</value>
private Dictionary<string, WIN32_FIND_DATA> MetadataFileDictionary { get; set; } private Dictionary<string, FileSystemInfo> MetadataFileDictionary { get; set; }
/// <summary> /// <summary>
/// Gets the metadata files. /// Gets the metadata files.
/// </summary> /// </summary>
/// <value>The metadata files.</value> /// <value>The metadata files.</value>
public IEnumerable<WIN32_FIND_DATA> MetadataFiles public IEnumerable<FileSystemInfo> MetadataFiles
{ {
get get
{ {
@ -202,7 +202,7 @@ namespace MediaBrowser.Controller.Library
return MetadataFileDictionary.Values; return MetadataFileDictionary.Values;
} }
return new WIN32_FIND_DATA[] {}; return new FileSystemInfo[] { };
} }
} }
@ -213,21 +213,21 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="System.IO.FileNotFoundException"></exception> /// <exception cref="System.IO.FileNotFoundException"></exception>
public void AddMetadataFile(string path) public void AddMetadataFile(string path)
{ {
var file = FileSystem.GetFileData(path); var file = FileSystem.GetFileSystemInfo(path);
if (!file.HasValue) if (!file.Exists)
{ {
throw new FileNotFoundException(path); throw new FileNotFoundException(path);
} }
AddMetadataFile(file.Value); AddMetadataFile(file);
} }
/// <summary> /// <summary>
/// Adds the metadata file. /// Adds the metadata file.
/// </summary> /// </summary>
/// <param name="fileInfo">The file info.</param> /// <param name="fileInfo">The file info.</param>
public void AddMetadataFile(WIN32_FIND_DATA fileInfo) public void AddMetadataFile(FileSystemInfo fileInfo)
{ {
AddMetadataFiles(new[] { fileInfo }); AddMetadataFiles(new[] { fileInfo });
} }
@ -237,7 +237,7 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
/// <param name="files">The files.</param> /// <param name="files">The files.</param>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public void AddMetadataFiles(IEnumerable<WIN32_FIND_DATA> files) public void AddMetadataFiles(IEnumerable<FileSystemInfo> files)
{ {
if (files == null) if (files == null)
{ {
@ -246,11 +246,11 @@ namespace MediaBrowser.Controller.Library
if (MetadataFileDictionary == null) if (MetadataFileDictionary == null)
{ {
MetadataFileDictionary = new Dictionary<string, WIN32_FIND_DATA>(StringComparer.OrdinalIgnoreCase); MetadataFileDictionary = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
} }
foreach (var file in files) foreach (var file in files)
{ {
MetadataFileDictionary[file.cFileName] = file; MetadataFileDictionary[file.Name] = file;
} }
} }
@ -258,9 +258,9 @@ namespace MediaBrowser.Controller.Library
/// Gets the name of the file system entry by. /// Gets the name of the file system entry by.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public WIN32_FIND_DATA? GetFileSystemEntryByName(string name) public FileSystemInfo GetFileSystemEntryByName(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -274,9 +274,9 @@ namespace MediaBrowser.Controller.Library
/// Gets the file system entry by path. /// Gets the file system entry by path.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public WIN32_FIND_DATA? GetFileSystemEntryByPath(string path) public FileSystemInfo GetFileSystemEntryByPath(string path)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -285,7 +285,7 @@ namespace MediaBrowser.Controller.Library
if (FileSystemDictionary != null) if (FileSystemDictionary != null)
{ {
WIN32_FIND_DATA entry; FileSystemInfo entry;
if (FileSystemDictionary.TryGetValue(path, out entry)) if (FileSystemDictionary.TryGetValue(path, out entry))
{ {
@ -300,9 +300,9 @@ namespace MediaBrowser.Controller.Library
/// Gets the meta file by path. /// Gets the meta file by path.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public WIN32_FIND_DATA? GetMetaFileByPath(string path) public FileSystemInfo GetMetaFileByPath(string path)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -311,7 +311,7 @@ namespace MediaBrowser.Controller.Library
if (MetadataFileDictionary != null) if (MetadataFileDictionary != null)
{ {
WIN32_FIND_DATA entry; FileSystemInfo entry;
if (MetadataFileDictionary.TryGetValue(System.IO.Path.GetFileName(path), out entry)) if (MetadataFileDictionary.TryGetValue(System.IO.Path.GetFileName(path), out entry))
{ {
@ -326,9 +326,9 @@ namespace MediaBrowser.Controller.Library
/// Gets the name of the meta file by. /// Gets the name of the meta file by.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>FileSystemInfo.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public WIN32_FIND_DATA? GetMetaFileByName(string name) public FileSystemInfo GetMetaFileByName(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -337,7 +337,7 @@ namespace MediaBrowser.Controller.Library
if (MetadataFileDictionary != null) if (MetadataFileDictionary != null)
{ {
WIN32_FIND_DATA entry; FileSystemInfo entry;
if (MetadataFileDictionary.TryGetValue(name, out entry)) if (MetadataFileDictionary.TryGetValue(name, out entry))
{ {
@ -355,7 +355,7 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if [contains meta file by name] [the specified name]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [contains meta file by name] [the specified name]; otherwise, <c>false</c>.</returns>
public bool ContainsMetaFileByName(string name) public bool ContainsMetaFileByName(string name)
{ {
return GetMetaFileByName(name).HasValue; return GetMetaFileByName(name) != null;
} }
/// <summary> /// <summary>
@ -365,7 +365,7 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if [contains file system entry by name] [the specified name]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [contains file system entry by name] [the specified name]; otherwise, <c>false</c>.</returns>
public bool ContainsFileSystemEntryByName(string name) public bool ContainsFileSystemEntryByName(string name)
{ {
return GetFileSystemEntryByName(name).HasValue; return GetFileSystemEntryByName(name) != null;
} }
#region Equality Overrides #region Equality Overrides

@ -1,4 +1,5 @@
using MediaBrowser.Controller.IO; using System.IO;
using MediaBrowser.Controller.IO;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -154,21 +155,21 @@ namespace MediaBrowser.Controller.Library
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="fileSystemChildren">The file system children.</param> /// <param name="fileSystemChildren">The file system children.</param>
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsSeriesFolder(string path, IEnumerable<WIN32_FIND_DATA> fileSystemChildren) public static bool IsSeriesFolder(string path, IEnumerable<FileSystemInfo> fileSystemChildren)
{ {
// A folder with more than 3 non-season folders in will not becounted as a series // A folder with more than 3 non-season folders in will not becounted as a series
var nonSeriesFolders = 0; var nonSeriesFolders = 0;
foreach (var child in fileSystemChildren) foreach (var child in fileSystemChildren)
{ {
if (child.IsHidden || child.IsSystemFile) if (child.Attributes.HasFlag(FileAttributes.Hidden) || child.Attributes.HasFlag(FileAttributes.System))
{ {
continue; continue;
} }
if (child.IsDirectory) if (child.Attributes.HasFlag(FileAttributes.Directory))
{ {
if (IsSeasonFolder(child.Path)) if (IsSeasonFolder(child.FullName))
{ {
return true; return true;
} }
@ -182,8 +183,8 @@ namespace MediaBrowser.Controller.Library
} }
else else
{ {
if (EntityResolutionHelper.IsVideoFile(child.Path) && if (EntityResolutionHelper.IsVideoFile(child.FullName) &&
!string.IsNullOrEmpty(EpisodeNumberFromFile(child.Path, false))) !string.IsNullOrEmpty(EpisodeNumberFromFile(child.FullName, false)))
{ {
return true; return true;
} }

@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Providers
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.MetaLocation != null ? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml")) : null; var entry = item.MetaLocation != null ? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml")) : null;
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>
@ -73,9 +73,9 @@ namespace MediaBrowser.Controller.Providers
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml"));
if (metadataFile.HasValue) if (metadataFile != null)
{ {
var path = metadataFile.Value.Path; var path = metadataFile.FullName;
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

@ -17,7 +17,8 @@ namespace MediaBrowser.Controller.Providers
/// </summary> /// </summary>
public class ImageFromMediaLocationProvider : BaseMetadataProvider public class ImageFromMediaLocationProvider : BaseMetadataProvider
{ {
public ImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager) public ImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
: base(logManager, configurationManager)
{ {
} }
@ -62,7 +63,7 @@ namespace MediaBrowser.Controller.Providers
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
// Make sure current image paths still exist // Make sure current image paths still exist
ValidateImages(item); ValidateImages(item);
@ -72,7 +73,7 @@ namespace MediaBrowser.Controller.Providers
ValidateBackdrops(item); ValidateBackdrops(item);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
PopulateBaseItemImages(item); PopulateBaseItemImages(item);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
@ -95,11 +96,11 @@ namespace MediaBrowser.Controller.Providers
{ {
var path = item.Images[image]; var path = item.Images[image];
return IsInMetaLocation(item, path) && !item.ResolveArgs.GetMetaFileByPath(path).HasValue; return IsInMetaLocation(item, path) && item.ResolveArgs.GetMetaFileByPath(path) == null;
}).ToList(); }).ToList();
// Now remove them from the dictionary // Now remove them from the dictionary
foreach(var key in deletedKeys) foreach (var key in deletedKeys)
{ {
item.Images.Remove(key); item.Images.Remove(key);
} }
@ -117,7 +118,7 @@ namespace MediaBrowser.Controller.Providers
} }
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
var deletedImages = item.BackdropImagePaths.Where(path => IsInMetaLocation(item, path) && !item.ResolveArgs.GetMetaFileByPath(path).HasValue).ToList(); var deletedImages = item.BackdropImagePaths.Where(path => IsInMetaLocation(item, path) && item.ResolveArgs.GetMetaFileByPath(path) == null).ToList();
// Now remove them from the dictionary // Now remove them from the dictionary
foreach (var path in deletedImages) foreach (var path in deletedImages)
@ -143,7 +144,7 @@ namespace MediaBrowser.Controller.Providers
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="filenameWithoutExtension">The filename without extension.</param> /// <param name="filenameWithoutExtension">The filename without extension.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>System.Nullable{WIN32_FIND_DATA}.</returns>
protected virtual WIN32_FIND_DATA? GetImage(BaseItem item, string filenameWithoutExtension) protected virtual FileSystemInfo GetImage(BaseItem item, string filenameWithoutExtension)
{ {
return item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.ResolveArgs.Path, filenameWithoutExtension + ".png")) ?? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.ResolveArgs.Path, filenameWithoutExtension + ".jpg")); return item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.ResolveArgs.Path, filenameWithoutExtension + ".png")) ?? item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.ResolveArgs.Path, filenameWithoutExtension + ".jpg"));
} }
@ -160,65 +161,65 @@ namespace MediaBrowser.Controller.Providers
// Primary Image // Primary Image
var image = GetImage(item, "folder"); var image = GetImage(item, "folder");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Primary, image.Value.Path); item.SetImage(ImageType.Primary, image.FullName);
} }
// Logo Image // Logo Image
image = GetImage(item, "logo"); image = GetImage(item, "logo");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Logo, image.Value.Path); item.SetImage(ImageType.Logo, image.FullName);
} }
// Banner Image // Banner Image
image = GetImage(item, "banner"); image = GetImage(item, "banner");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Banner, image.Value.Path); item.SetImage(ImageType.Banner, image.FullName);
} }
// Clearart // Clearart
image = GetImage(item, "clearart"); image = GetImage(item, "clearart");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Art, image.Value.Path); item.SetImage(ImageType.Art, image.FullName);
} }
// Thumbnail Image // Thumbnail Image
image = GetImage(item, "thumb"); image = GetImage(item, "thumb");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Thumb, image.Value.Path); item.SetImage(ImageType.Thumb, image.FullName);
} }
// Thumbnail Image // Thumbnail Image
image = GetImage(item, "box"); image = GetImage(item, "box");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Box, image.Value.Path); item.SetImage(ImageType.Box, image.FullName);
} }
// Thumbnail Image // Thumbnail Image
image = GetImage(item, "menu"); image = GetImage(item, "menu");
if (image.HasValue) if (image != null)
{ {
item.SetImage(ImageType.Menu, image.Value.Path); item.SetImage(ImageType.Menu, image.FullName);
} }
// Backdrop Image // Backdrop Image
image = GetImage(item, "backdrop"); image = GetImage(item, "backdrop");
if (image.HasValue) if (image != null)
{ {
backdropFiles.Add(image.Value.Path); backdropFiles.Add(image.FullName);
} }
var unfound = 0; var unfound = 0;
@ -227,9 +228,9 @@ namespace MediaBrowser.Controller.Providers
// Backdrop Image // Backdrop Image
image = GetImage(item, "backdrop" + i); image = GetImage(item, "backdrop" + i);
if (image.HasValue) if (image != null)
{ {
backdropFiles.Add(image.Value.Path); backdropFiles.Add(image.FullName);
} }
else else
{ {
@ -250,9 +251,9 @@ namespace MediaBrowser.Controller.Providers
// Screenshot Image // Screenshot Image
image = GetImage(item, "screenshot"); image = GetImage(item, "screenshot");
if (image.HasValue) if (image != null)
{ {
screenshotFiles.Add(image.Value.Path); screenshotFiles.Add(image.FullName);
} }
unfound = 0; unfound = 0;
@ -261,9 +262,9 @@ namespace MediaBrowser.Controller.Providers
// Screenshot Image // Screenshot Image
image = GetImage(item, "screenshot" + i); image = GetImage(item, "screenshot" + i);
if (image.HasValue) if (image != null)
{ {
screenshotFiles.Add(image.Value.Path); screenshotFiles.Add(image.FullName);
} }
else else
{ {

@ -88,7 +88,7 @@ namespace MediaBrowser.Controller.Providers
return DateTime.MinValue; return DateTime.MinValue;
} }
var files = new DirectoryInfo(location).EnumerateFiles("*", SearchOption.TopDirectoryOnly).ToList(); var files = new DirectoryInfo(location).EnumerateFiles().ToList();
if (files.Count == 0) if (files.Count == 0)
{ {
@ -97,54 +97,14 @@ namespace MediaBrowser.Controller.Providers
return files.Select(f => return files.Select(f =>
{ {
var lastWriteTime = GetLastWriteTimeUtc(f); var lastWriteTime = FileSystem.GetLastWriteTimeUtc(f, Logger);
var creationTime = GetCreationTimeUtc(f); var creationTime = FileSystem.GetCreationTimeUtc(f, Logger);
return creationTime > lastWriteTime ? creationTime : lastWriteTime; return creationTime > lastWriteTime ? creationTime : lastWriteTime;
}).Max(); }).Max();
} }
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="info">The info.</param>
/// <returns>DateTime.</returns>
private DateTime GetLastWriteTimeUtc(FileSystemInfo info)
{
// This could throw an error on some file systems that have dates out of range
try
{
return info.LastAccessTimeUtc;
}
catch (Exception ex)
{
Logger.ErrorException("Error determining LastAccessTimeUtc for {0}", ex, info.FullName);
return DateTime.MinValue;
}
}
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="info">The info.</param>
/// <returns>DateTime.</returns>
private DateTime GetCreationTimeUtc(FileSystemInfo info)
{
// This could throw an error on some file systems that have dates out of range
try
{
return info.CreationTimeUtc;
}
catch (Exception ex)
{
Logger.ErrorException("Error determining CreationTimeUtc for {0}", ex, info.FullName);
return DateTime.MinValue;
}
}
/// <summary> /// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary> /// </summary>
@ -184,15 +144,21 @@ namespace MediaBrowser.Controller.Providers
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="filenameWithoutExtension">The filename without extension.</param> /// <param name="filenameWithoutExtension">The filename without extension.</param>
/// <returns>System.Nullable{WIN32_FIND_DATA}.</returns> /// <returns>System.Nullable{WIN32_FIND_DATA}.</returns>
protected override WIN32_FIND_DATA? GetImage(BaseItem item, string filenameWithoutExtension) protected override FileSystemInfo GetImage(BaseItem item, string filenameWithoutExtension)
{ {
var location = GetLocation(item); var location = GetLocation(item);
var result = FileSystem.GetFileData(Path.Combine(location, filenameWithoutExtension + ".png")); var result = new FileInfo(Path.Combine(location, filenameWithoutExtension + ".png"));
if (!result.HasValue)
result = FileSystem.GetFileData(Path.Combine(location, filenameWithoutExtension + ".jpg"));
return result; if (!result.Exists)
result = new FileInfo(Path.Combine(location, filenameWithoutExtension + ".jpg"));
if (result.Exists)
{
return result;
}
return null;
} }
} }
} }

@ -255,16 +255,17 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
var startIndex = video.MediaStreams == null ? 0 : video.MediaStreams.Count; var startIndex = video.MediaStreams == null ? 0 : video.MediaStreams.Count;
var streams = new List<MediaStream>(); var streams = new List<MediaStream>();
foreach (var file in fileSystemChildren.Where(f => !f.IsDirectory)) foreach (var file in fileSystemChildren.Where(f => !f.Attributes.HasFlag(FileAttributes.Directory)))
{ {
var extension = Path.GetExtension(file.Path); var fullName = file.FullName;
var extension = Path.GetExtension(fullName);
if (string.Equals(extension, ".srt", StringComparison.OrdinalIgnoreCase)) if (string.Equals(extension, ".srt", StringComparison.OrdinalIgnoreCase))
{ {
if (video.VideoType == VideoType.VideoFile) if (video.VideoType == VideoType.VideoFile)
{ {
// For video files the subtitle filename must match video filename // For video files the subtitle filename must match video filename
if (!string.Equals(Path.GetFileNameWithoutExtension(video.Path), Path.GetFileNameWithoutExtension(file.Path))) if (!string.Equals(Path.GetFileNameWithoutExtension(video.Path), Path.GetFileNameWithoutExtension(fullName)))
{ {
continue; continue;
} }
@ -275,7 +276,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
Index = startIndex++, Index = startIndex++,
Type = MediaStreamType.Subtitle, Type = MediaStreamType.Subtitle,
IsExternal = true, IsExternal = true,
Path = file.Path, Path = fullName,
Codec = "srt" Codec = "srt"
}); });
} }

@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Providers.Movies
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME)); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>
@ -84,10 +84,10 @@ namespace MediaBrowser.Controller.Providers.Movies
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME)); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
if (entry.HasValue) if (entry != null)
{ {
// read in our saved meta and pass to processing function // read in our saved meta and pass to processing function
var movieData = JsonSerializer.DeserializeFromFile<CompleteMovieData>(entry.Value.Path); var movieData = JsonSerializer.DeserializeFromFile<CompleteMovieData>(entry.FullName);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Providers.Movies
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "movie.xml")); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "movie.xml"));
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>
@ -73,9 +73,9 @@ namespace MediaBrowser.Controller.Providers.Movies
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "movie.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "movie.xml"));
if (metadataFile.HasValue) if (metadataFile != null)
{ {
var path = metadataFile.Value.Path; var path = metadataFile.FullName;
var boxset = item as BoxSet; var boxset = item as BoxSet;
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Providers.Movies
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation,MetaFileName)); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation,MetaFileName));
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>

@ -35,10 +35,10 @@ namespace MediaBrowser.Controller.Providers.Music
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName)); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName));
if (entry.HasValue) if (entry != null)
{ {
// read in our saved meta and pass to processing function // read in our saved meta and pass to processing function
var data = JsonSerializer.DeserializeFromFile<LastfmArtist>(entry.Value.Path); var data = JsonSerializer.DeserializeFromFile<LastfmArtist>(entry.FullName);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.Music
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName)); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName));
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
} }

@ -15,7 +15,8 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary> /// </summary>
public class EpisodeImageFromMediaLocationProvider : BaseMetadataProvider public class EpisodeImageFromMediaLocationProvider : BaseMetadataProvider
{ {
public EpisodeImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager) public EpisodeImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
: base(logManager, configurationManager)
{ {
} }
@ -60,7 +61,7 @@ namespace MediaBrowser.Controller.Providers.TV
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var episode = (Episode)item; var episode = (Episode)item;
var episodeFileName = Path.GetFileName(episode.Path); var episodeFileName = Path.GetFileName(episode.Path);
@ -70,7 +71,7 @@ namespace MediaBrowser.Controller.Providers.TV
ValidateImage(episode, item.MetaLocation); ValidateImage(episode, item.MetaLocation);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
SetPrimaryImagePath(episode, parent, item.MetaLocation, episodeFileName); SetPrimaryImagePath(episode, parent, item.MetaLocation, episodeFileName);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
@ -98,7 +99,7 @@ namespace MediaBrowser.Controller.Providers.TV
return; return;
} }
if (!episode.Parent.ResolveArgs.GetMetaFileByPath(path).HasValue) if (episode.Parent.ResolveArgs.GetMetaFileByPath(path) == null)
{ {
episode.PrimaryImagePath = null; episode.PrimaryImagePath = null;
} }
@ -122,9 +123,9 @@ namespace MediaBrowser.Controller.Providers.TV
var file = parent.ResolveArgs.GetMetaFileByPath(imageFiles[0]) ?? var file = parent.ResolveArgs.GetMetaFileByPath(imageFiles[0]) ??
parent.ResolveArgs.GetMetaFileByPath(imageFiles[1]); parent.ResolveArgs.GetMetaFileByPath(imageFiles[1]);
if (file.HasValue) if (file != null)
{ {
item.PrimaryImagePath = file.Value.Path; item.PrimaryImagePath = file.FullName;
} }
} }
} }

@ -71,12 +71,12 @@ namespace MediaBrowser.Controller.Providers.TV
var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile); var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);
if (!file.HasValue) if (file == null)
{ {
return base.CompareDate(item); return base.CompareDate(item);
} }
return file.Value.LastWriteTimeUtc; return file.LastWriteTimeUtc;
} }
/// <summary> /// <summary>
@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.TV
var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile); var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);
if (!file.HasValue) if (file == null)
{ {
return false; return false;
} }

@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Providers.TV
protected override DateTime CompareDate(BaseItem item) protected override DateTime CompareDate(BaseItem item)
{ {
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml")); var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml"));
return entry != null ? entry.Value.LastWriteTimeUtc : DateTime.MinValue; return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
} }
/// <summary> /// <summary>
@ -74,9 +74,9 @@ namespace MediaBrowser.Controller.Providers.TV
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml")); var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "series.xml"));
if (metadataFile.HasValue) if (metadataFile != null)
{ {
var path = metadataFile.Value.Path; var path = metadataFile.FullName;
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);

@ -72,19 +72,19 @@ namespace MediaBrowser.Controller.Resolvers
{ {
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null; var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
if (childData.HasValue) if (childData != null)
{ {
item.DateCreated = childData.Value.CreationTimeUtc; item.DateCreated = childData.CreationTimeUtc;
item.DateModified = childData.Value.LastWriteTimeUtc; item.DateModified = childData.LastWriteTimeUtc;
} }
else else
{ {
var fileData = FileSystem.GetFileData(item.Path); var fileData = FileSystem.GetFileSystemInfo(item.Path);
if (fileData.HasValue) if (fileData.Exists)
{ {
item.DateCreated = fileData.Value.CreationTimeUtc; item.DateCreated = fileData.CreationTimeUtc;
item.DateModified = fileData.Value.LastWriteTimeUtc; item.DateModified = fileData.LastWriteTimeUtc;
} }
} }
} }

@ -394,9 +394,9 @@ namespace MediaBrowser.Server.Implementations.IO
{ {
try try
{ {
var data = FileSystem.GetFileData(path); var data = FileSystem.GetFileSystemInfo(path);
if (!data.HasValue || data.Value.IsDirectory) if (!data.Exists || data.Attributes.HasFlag(FileAttributes.Directory))
{ {
return false; return false;
} }

@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (args.IsDirectory) if (args.IsDirectory)
{ {
var filename = args.FileInfo.cFileName; var filename = args.FileInfo.Name;
// Ignore any folders in our list // Ignore any folders in our list
if (IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase)) if (IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase))

@ -403,16 +403,16 @@ namespace MediaBrowser.Server.Implementations.Library
/// <param name="fileInfo">The file info.</param> /// <param name="fileInfo">The file info.</param>
/// <returns>BaseItem.</returns> /// <returns>BaseItem.</returns>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
public BaseItem ResolvePath(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null) public BaseItem ResolvePath(string path, Folder parent = null, FileSystemInfo fileInfo = null)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
throw new ArgumentNullException(); throw new ArgumentNullException();
} }
fileInfo = fileInfo ?? FileSystem.GetFileData(path); fileInfo = fileInfo ?? FileSystem.GetFileSystemInfo(path);
if (!fileInfo.HasValue) if (!fileInfo.Exists)
{ {
return null; return null;
} }
@ -421,7 +421,7 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
Parent = parent, Parent = parent,
Path = path, Path = path,
FileInfo = fileInfo.Value FileInfo = fileInfo
}; };
// Return null if ignore rules deem that we should do so // Return null if ignore rules deem that we should do so
@ -468,7 +468,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <param name="files">The files.</param> /// <param name="files">The files.</param>
/// <param name="parent">The parent.</param> /// <param name="parent">The parent.</param>
/// <returns>List{``0}.</returns> /// <returns>List{``0}.</returns>
public List<T> ResolvePaths<T>(IEnumerable<WIN32_FIND_DATA> files, Folder parent) public List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, Folder parent)
where T : BaseItem where T : BaseItem
{ {
var list = new List<T>(); var list = new List<T>();
@ -477,7 +477,7 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
try try
{ {
var item = ResolvePath(f.Path, parent, f) as T; var item = ResolvePath(f.FullName, parent, f) as T;
if (item != null) if (item != null)
{ {
@ -489,7 +489,7 @@ namespace MediaBrowser.Server.Implementations.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.ErrorException("Error resolving path {0}", ex, f.Path); _logger.ErrorException("Error resolving path {0}", ex, f.FullName);
} }
}); });
@ -680,16 +680,16 @@ namespace MediaBrowser.Server.Implementations.Library
path = Path.Combine(path, FileSystem.GetValidFilename(name)); path = Path.Combine(path, FileSystem.GetValidFilename(name));
var fileInfo = FileSystem.GetFileData(path); var fileInfo = new DirectoryInfo(path);
var isNew = false; var isNew = false;
if (!fileInfo.HasValue) if (!fileInfo.Exists)
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
fileInfo = FileSystem.GetFileData(path); fileInfo = new DirectoryInfo(path);
if (!fileInfo.HasValue) if (!fileInfo.Exists)
{ {
throw new IOException("Path not created: " + path); throw new IOException("Path not created: " + path);
} }
@ -708,8 +708,8 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
Name = name, Name = name,
Id = id, Id = id,
DateCreated = fileInfo.Value.CreationTimeUtc, DateCreated = fileInfo.CreationTimeUtc,
DateModified = fileInfo.Value.LastWriteTimeUtc, DateModified = fileInfo.LastWriteTimeUtc,
Path = path Path = path
}; };
isNew = true; isNew = true;

@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path)) if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
{ {
//we use our resolve args name here to get the name of the containg folder, not actual video file //we use our resolve args name here to get the name of the containg folder, not actual video file
item.Name = GetMBName(item.ResolveArgs.FileInfo.cFileName, item.ResolveArgs.FileInfo.IsDirectory); item.Name = GetMBName(item.ResolveArgs.FileInfo.Name, item.ResolveArgs.FileInfo.Attributes.HasFlag(FileAttributes.Directory));
} }
} }

@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
// If list contains at least 2 audio files or at least one and no video files consider it to contain music // If list contains at least 2 audio files or at least one and no video files consider it to contain music
var foundAudio = 0; var foundAudio = 0;
foreach (var fullName in new DirectoryInfo(path).EnumerateFiles("*", SearchOption.TopDirectoryOnly).Select(file => file.FullName)) foreach (var fullName in new DirectoryInfo(path).EnumerateFiles().Select(file => file.FullName))
{ {
if (AudioResolver.IsAudioFile(fullName)) foundAudio++; if (AudioResolver.IsAudioFile(fullName)) foundAudio++;
if (foundAudio >= 2) if (foundAudio >= 2)
@ -86,19 +86,19 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
/// </summary> /// </summary>
/// <param name="list">The list.</param> /// <param name="list">The list.</param>
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
public static bool ContainsMusic(IEnumerable<WIN32_FIND_DATA> list) public static bool ContainsMusic(IEnumerable<FileSystemInfo> list)
{ {
// If list contains at least 2 audio files or at least one and no video files consider it to contain music // If list contains at least 2 audio files or at least one and no video files consider it to contain music
var foundAudio = 0; var foundAudio = 0;
foreach (var file in list) foreach (var file in list)
{ {
if (AudioResolver.IsAudioFile(file.Path)) foundAudio++; if (AudioResolver.IsAudioFile(file.FullName)) foundAudio++;
if (foundAudio >= 2) if (foundAudio >= 2)
{ {
return true; return true;
} }
if (EntityResolutionHelper.IsVideoFile(file.Path)) return false; if (EntityResolutionHelper.IsVideoFile(file.FullName)) return false;
} }
// or a single audio file and no video files // or a single audio file and no video files

@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
if (args.Parent.IsRoot) return null; if (args.Parent.IsRoot) return null;
// If we contain an album assume we are an artist folder // If we contain an album assume we are an artist folder
return args.FileSystemChildren.Any(i => MusicAlbumResolver.IsMusicAlbum(i.Path)) ? new MusicArtist() : null; return args.FileSystemChildren.Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
} }
} }

@ -127,9 +127,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Loop through each child file/folder and see if we find a video // Loop through each child file/folder and see if we find a video
foreach (var child in args.FileSystemChildren) foreach (var child in args.FileSystemChildren)
{ {
if (child.IsDirectory) if (child.Attributes.HasFlag(FileAttributes.Directory))
{ {
if (IsDvdDirectory(child.cFileName)) if (IsDvdDirectory(child.Name))
{ {
return new Movie return new Movie
{ {
@ -137,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
VideoType = VideoType.Dvd VideoType = VideoType.Dvd
}; };
} }
if (IsBluRayDirectory(child.cFileName)) if (IsBluRayDirectory(child.Name))
{ {
return new Movie return new Movie
{ {
@ -145,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
VideoType = VideoType.BluRay VideoType = VideoType.BluRay
}; };
} }
if (IsHdDvdDirectory(child.cFileName)) if (IsHdDvdDirectory(child.Name))
{ {
return new Movie return new Movie
{ {
@ -160,7 +160,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
var childArgs = new ItemResolveArgs(ApplicationPaths) var childArgs = new ItemResolveArgs(ApplicationPaths)
{ {
FileInfo = child, FileInfo = child,
Path = child.Path Path = child.FullName
}; };
var item = base.Resolve(childArgs); var item = base.Resolve(childArgs);

Loading…
Cancel
Save