This commit is contained in:
Luke Pulverenti 2017-03-29 02:26:48 -04:00
parent 2dbe162e45
commit 04b6f23473
26 changed files with 159 additions and 139 deletions

View File

@ -135,13 +135,13 @@ namespace BDInfo
{ {
IsBDPlus = true; IsBDPlus = true;
} }
if (DirectoryBDJO != null && if (DirectoryBDJO != null &&
_fileSystem.GetFiles(DirectoryBDJO.FullName).Any()) _fileSystem.GetFiles(DirectoryBDJO.FullName).Any())
{ {
IsBDJava = true; IsBDJava = true;
} }
if (DirectorySNP != null && if (DirectorySNP != null &&
GetFiles(DirectorySNP.FullName, ".mnv").Any()) GetFiles(DirectorySNP.FullName, ".mnv").Any())
{ {
@ -206,7 +206,7 @@ namespace BDInfo
private IEnumerable<FileSystemMetadata> GetFiles(string path, string extension) private IEnumerable<FileSystemMetadata> GetFiles(string path, string extension)
{ {
return _fileSystem.GetFiles(path).Where(i => string.Equals(i.Extension, extension, StringComparison.OrdinalIgnoreCase)); return _fileSystem.GetFiles(path, new[] { extension }, false, false);
} }
public void Scan() public void Scan()

View File

@ -657,14 +657,41 @@ namespace Emby.Common.Implementations.IO
{ {
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
return ToMetadata(path, new DirectoryInfo(path).EnumerateDirectories("*", searchOption)); return ToMetadata(new DirectoryInfo(path).EnumerateDirectories("*", searchOption));
} }
public IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false) public IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false)
{
return GetFiles(path, null, true, recursive);
}
public IEnumerable<FileSystemMetadata> GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
{ {
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
return ToMetadata(path, new DirectoryInfo(path).EnumerateFiles("*", searchOption)); // On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if (enableCaseSensitiveExtensions && extensions != null && extensions.Length == 1)
{
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], searchOption));
}
var files = new DirectoryInfo(path).EnumerateFiles("*", searchOption);
if (extensions != null && extensions.Length > 0)
{
files = files.Where(i =>
{
var ext = i.Extension;
if (ext == null)
{
return false;
}
return extensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
});
}
return ToMetadata(files);
} }
public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false) public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false)
@ -674,14 +701,14 @@ namespace Emby.Common.Implementations.IO
if (EnableFileSystemRequestConcat) if (EnableFileSystemRequestConcat)
{ {
return ToMetadata(path, directoryInfo.EnumerateDirectories("*", searchOption)) return ToMetadata(directoryInfo.EnumerateDirectories("*", searchOption))
.Concat(ToMetadata(path, directoryInfo.EnumerateFiles("*", searchOption))); .Concat(ToMetadata(directoryInfo.EnumerateFiles("*", searchOption)));
} }
return ToMetadata(path, directoryInfo.EnumerateFileSystemInfos("*", searchOption)); return ToMetadata(directoryInfo.EnumerateFileSystemInfos("*", searchOption));
} }
private IEnumerable<FileSystemMetadata> ToMetadata(string parentPath, IEnumerable<FileSystemInfo> infos) private IEnumerable<FileSystemMetadata> ToMetadata(IEnumerable<FileSystemInfo> infos)
{ {
return infos.Select(GetFileSystemMetadata); return infos.Select(GetFileSystemMetadata);
} }
@ -776,7 +803,7 @@ namespace Emby.Common.Implementations.IO
public virtual void SetExecutable(string path) public virtual void SetExecutable(string path)
{ {
} }
} }
} }

View File

@ -286,19 +286,12 @@ namespace Emby.Dlna
{ {
try try
{ {
var allFiles = _fileSystem.GetFiles(path) var xmlFies = _fileSystem.GetFilePaths(path)
.Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
var xmlFies = allFiles return xmlFies
.Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase)) .Select(i => ParseProfileFile(i, type))
.ToList();
var parseFiles = new List<FileSystemMetadata>();
parseFiles.AddRange(xmlFies);
return parseFiles
.Select(i => ParseProfileFile(i.FullName, type))
.Where(i => i != null) .Where(i => i != null)
.ToList(); .ToList();
} }
@ -322,16 +315,9 @@ namespace Emby.Dlna
{ {
DeviceProfile profile; DeviceProfile profile;
if (string.Equals(Path.GetExtension(path), ".xml", StringComparison.OrdinalIgnoreCase)) var tempProfile = (DeviceProfile)_xmlSerializer.DeserializeFromFile(typeof(DeviceProfile), path);
{
var tempProfile = (DeviceProfile)_xmlSerializer.DeserializeFromFile(typeof(DeviceProfile), path);
profile = ReserializeProfile(tempProfile); profile = ReserializeProfile(tempProfile);
}
else
{
profile = (DeviceProfile)_jsonSerializer.DeserializeFromFile(typeof(DeviceProfile), path);
}
profile.Id = path.ToLower().GetMD5().ToString("N"); profile.Id = path.ToLower().GetMD5().ToString("N");
profile.ProfileType = type; profile.ProfileType = type;
@ -553,15 +539,13 @@ namespace Emby.Dlna
class DlnaProfileEntryPoint : IServerEntryPoint class DlnaProfileEntryPoint : IServerEntryPoint
{ {
private readonly IApplicationPaths _appPaths; private readonly IApplicationPaths _appPaths;
private readonly IJsonSerializer _jsonSerializer;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IXmlSerializer _xmlSerializer; private readonly IXmlSerializer _xmlSerializer;
public DlnaProfileEntryPoint(IApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer) public DlnaProfileEntryPoint(IApplicationPaths appPaths, IFileSystem fileSystem, IXmlSerializer xmlSerializer)
{ {
_appPaths = appPaths; _appPaths = appPaths;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_jsonSerializer = jsonSerializer;
_xmlSerializer = xmlSerializer; _xmlSerializer = xmlSerializer;
} }

View File

@ -151,8 +151,7 @@ namespace Emby.Server.Implementations.FileOrganization
/// <param name="extensions">The extensions.</param> /// <param name="extensions">The extensions.</param>
private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions) private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions)
{ {
var eligibleFiles = _fileSystem.GetFiles(path, true) var eligibleFiles = _fileSystem.GetFiles(path, extensions.ToArray(), false, true)
.Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
.ToList(); .ToList();
foreach (var file in eligibleFiles) foreach (var file in eligibleFiles)

View File

@ -448,7 +448,7 @@ namespace Emby.Server.Implementations.Library
if (parent != null) if (parent != null)
{ {
await parent.ValidateChildren(new Progress<double>(), CancellationToken.None, new MetadataRefreshOptions(_fileSystem), false) .ConfigureAwait(false); await parent.ValidateChildren(new Progress<double>(), CancellationToken.None, new MetadataRefreshOptions(_fileSystem), false).ConfigureAwait(false);
} }
} }
else if (parent != null) else if (parent != null)
@ -941,7 +941,7 @@ namespace Emby.Server.Implementations.Library
return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name); return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name);
} }
private T CreateItemByName<T>(Func<string,string> getPathFn, string name) private T CreateItemByName<T>(Func<string, string> getPathFn, string name)
where T : BaseItem, new() where T : BaseItem, new()
{ {
if (typeof(T) == typeof(MusicArtist)) if (typeof(T) == typeof(MusicArtist))
@ -1255,8 +1255,7 @@ namespace Emby.Server.Implementations.Library
private string GetCollectionType(string path) private string GetCollectionType(string path)
{ {
return _fileSystem.GetFiles(path, false) return _fileSystem.GetFiles(path, new[] { ".collection" }, true, false)
.Where(i => string.Equals(i.Extension, ".collection", StringComparison.OrdinalIgnoreCase))
.Select(i => _fileSystem.GetFileNameWithoutExtension(i)) .Select(i => _fileSystem.GetFileNameWithoutExtension(i))
.FirstOrDefault(); .FirstOrDefault();
} }
@ -2474,29 +2473,36 @@ namespace Emby.Server.Implementations.Library
return GetNamingOptions(new LibraryOptions()); return GetNamingOptions(new LibraryOptions());
} }
private NamingOptions _namingOptions;
private string[] _videoFileExtensions;
public NamingOptions GetNamingOptions(LibraryOptions libraryOptions) public NamingOptions GetNamingOptions(LibraryOptions libraryOptions)
{ {
var options = new ExtendedNamingOptions(); if (_namingOptions == null)
// These cause apps to have problems
options.AudioFileExtensions.Remove(".m3u");
options.AudioFileExtensions.Remove(".wpl");
if (!libraryOptions.EnableArchiveMediaFiles)
{ {
options.AudioFileExtensions.Remove(".rar"); var options = new ExtendedNamingOptions();
options.AudioFileExtensions.Remove(".zip");
// These cause apps to have problems
options.AudioFileExtensions.Remove(".m3u");
options.AudioFileExtensions.Remove(".wpl");
//if (!libraryOptions.EnableArchiveMediaFiles)
{
options.AudioFileExtensions.Remove(".rar");
options.AudioFileExtensions.Remove(".zip");
}
//if (!libraryOptions.EnableArchiveMediaFiles)
{
options.VideoFileExtensions.Remove(".rar");
options.VideoFileExtensions.Remove(".zip");
}
options.VideoFileExtensions.Add(".tp");
_namingOptions = options;
_videoFileExtensions = _namingOptions.VideoFileExtensions.ToArray();
} }
if (!libraryOptions.EnableArchiveMediaFiles) return _namingOptions;
{
options.VideoFileExtensions.Remove(".rar");
options.VideoFileExtensions.Remove(".zip");
}
options.VideoFileExtensions.Add(".tp");
return options;
} }
public ItemLookupInfo ParseName(string name) public ItemLookupInfo ParseName(string name)
@ -2515,12 +2521,14 @@ namespace Emby.Server.Implementations.Library
public IEnumerable<Video> FindTrailers(BaseItem owner, List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) public IEnumerable<Video> FindTrailers(BaseItem owner, List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
{ {
var namingOptions = GetNamingOptions();
var files = owner.DetectIsInMixedFolder() ? new List<FileSystemMetadata>() : fileSystemChildren.Where(i => i.IsDirectory) var files = owner.DetectIsInMixedFolder() ? new List<FileSystemMetadata>() : fileSystemChildren.Where(i => i.IsDirectory)
.Where(i => string.Equals(i.Name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase)) .Where(i => string.Equals(i.Name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
.SelectMany(i => _fileSystem.GetFiles(i.FullName, false)) .SelectMany(i => _fileSystem.GetFiles(i.FullName, _videoFileExtensions, false, false))
.ToList(); .ToList();
var videoListResolver = new VideoListResolver(GetNamingOptions(), new NullLogger()); var videoListResolver = new VideoListResolver(namingOptions, new NullLogger());
var videos = videoListResolver.Resolve(fileSystemChildren); var videos = videoListResolver.Resolve(fileSystemChildren);
@ -2561,12 +2569,14 @@ namespace Emby.Server.Implementations.Library
public IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) public IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
{ {
var namingOptions = GetNamingOptions();
var files = fileSystemChildren.Where(i => i.IsDirectory) var files = fileSystemChildren.Where(i => i.IsDirectory)
.Where(i => ExtrasSubfolderNames.Contains(i.Name ?? string.Empty, StringComparer.OrdinalIgnoreCase)) .Where(i => ExtrasSubfolderNames.Contains(i.Name ?? string.Empty, StringComparer.OrdinalIgnoreCase))
.SelectMany(i => _fileSystem.GetFiles(i.FullName, false)) .SelectMany(i => _fileSystem.GetFiles(i.FullName, _videoFileExtensions, false, false))
.ToList(); .ToList();
var videoListResolver = new VideoListResolver(GetNamingOptions(), new NullLogger()); var videoListResolver = new VideoListResolver(namingOptions, new NullLogger());
var videos = videoListResolver.Resolve(fileSystemChildren); var videos = videoListResolver.Resolve(fileSystemChildren);

View File

@ -276,7 +276,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
return false; return false;
} }
return directoryService.GetFiles(fullPath).Any(i => string.Equals(i.Extension, ".vob", StringComparison.OrdinalIgnoreCase)); return directoryService.GetFilePaths(fullPath).Any(i => string.Equals(Path.GetExtension(i), ".vob", StringComparison.OrdinalIgnoreCase));
} }
/// <summary> /// <summary>

View File

@ -5,10 +5,6 @@ using MediaBrowser.Model.Entities;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
namespace Emby.Server.Implementations.Library.Resolvers namespace Emby.Server.Implementations.Library.Resolvers
@ -45,7 +41,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
var filename = Path.GetFileNameWithoutExtension(args.Path); var filename = Path.GetFileNameWithoutExtension(args.Path);
// Make sure the image doesn't belong to a video file // Make sure the image doesn't belong to a video file
if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename))) if (args.DirectoryService.GetFilePaths(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
{ {
return null; return null;
} }
@ -61,11 +57,14 @@ namespace Emby.Server.Implementations.Library.Resolvers
return null; return null;
} }
private bool IsOwnedByMedia(LibraryOptions libraryOptions, FileSystemMetadata file, string imageFilename) private bool IsOwnedByMedia(LibraryOptions libraryOptions, string file, string imageFilename)
{ {
if (_libraryManager.IsVideoFile(file.FullName, libraryOptions) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase)) if (_libraryManager.IsVideoFile(file, libraryOptions))
{ {
return true; if (imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file), StringComparison.OrdinalIgnoreCase))
{
return true;
}
} }
return false; return false;

View File

@ -135,8 +135,7 @@ namespace MediaBrowser.Api.Images
{ {
try try
{ {
return _fileSystem.GetFiles(path, true) return _fileSystem.GetFiles(path, BaseItem.SupportedImageExtensions, false, true)
.Where(i => BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.Ordinal))
.Select(i => new ImageByNameInfo .Select(i => new ImageByNameInfo
{ {
Name = _fileSystem.GetFileNameWithoutExtension(i), Name = _fileSystem.GetFileNameWithoutExtension(i),

View File

@ -345,34 +345,34 @@ namespace MediaBrowser.Api.Playback.Hls
if (file != null) if (file != null)
{ {
DeleteFile(file, retryCount); DeleteFile(file.FullName, retryCount);
} }
} }
private void DeleteFile(FileSystemMetadata file, int retryCount) private void DeleteFile(string path, int retryCount)
{ {
if (retryCount >= 5) if (retryCount >= 5)
{ {
return; return;
} }
Logger.Debug("Deleting partial HLS file {0}", file.FullName); Logger.Debug("Deleting partial HLS file {0}", path);
try try
{ {
FileSystem.DeleteFile(file.FullName); FileSystem.DeleteFile(path);
} }
catch (IOException ex) catch (IOException ex)
{ {
Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, file.FullName); Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path);
var task = Task.Delay(100); var task = Task.Delay(100);
Task.WaitAll(task); Task.WaitAll(task);
DeleteFile(file, retryCount + 1); DeleteFile(path, retryCount + 1);
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, file.FullName); Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path);
} }
} }
@ -384,8 +384,8 @@ namespace MediaBrowser.Api.Playback.Hls
try try
{ {
return fileSystem.GetFiles(folder) return fileSystem.GetFiles(folder, new[] { segmentExtension }, true, false)
.Where(i => string.Equals(i.Extension, segmentExtension, StringComparison.OrdinalIgnoreCase) && Path.GetFileNameWithoutExtension(i.Name).StartsWith(filePrefix, StringComparison.OrdinalIgnoreCase)) .Where(i => Path.GetFileNameWithoutExtension(i.Name).StartsWith(filePrefix, StringComparison.OrdinalIgnoreCase))
.OrderByDescending(fileSystem.GetLastWriteTimeUtc) .OrderByDescending(fileSystem.GetLastWriteTimeUtc)
.FirstOrDefault(); .FirstOrDefault();
} }

View File

@ -94,7 +94,6 @@ namespace MediaBrowser.Api
{ {
config.EnableStandaloneMusicKeys = true; config.EnableStandaloneMusicKeys = true;
config.EnableCaseSensitiveItemIds = true; config.EnableCaseSensitiveItemIds = true;
config.EnableFolderView = true;
config.SkipDeserializationForBasicTypes = true; config.SkipDeserializationForBasicTypes = true;
config.SkipDeserializationForPrograms = true; config.SkipDeserializationForPrograms = true;
config.SkipDeserializationForAudio = true; config.SkipDeserializationForAudio = true;

View File

@ -122,8 +122,7 @@ namespace MediaBrowser.Api.System
try try
{ {
files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath) files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath, new[] { ".txt" }, true, false)
.Where(i => string.Equals(i.Extension, ".txt", StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
} }
catch (IOException) catch (IOException)

View File

@ -27,6 +27,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary> /// <summary>
/// We don't support manual shortcuts /// We don't support manual shortcuts
/// </summary> /// </summary>
[IgnoreDataMember]
protected override bool SupportsShortcutChildren protected override bool SupportsShortcutChildren
{ {
get get

View File

@ -1926,8 +1926,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => i.IsLocalFile) .Where(i => i.IsLocalFile)
.Select(i => System.IO.Path.GetDirectoryName(i.Path)) .Select(i => System.IO.Path.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.SelectMany(directoryService.GetFiles) .SelectMany(directoryService.GetFilePaths)
.Select(i => i.FullName)
.ToList(); .ToList();
var deletedImages = ImageInfos var deletedImages = ImageInfos
@ -2100,8 +2099,8 @@ namespace MediaBrowser.Controller.Entities
var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList(); var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList();
extensions.AddRange(SupportedImageExtensionsList); extensions.AddRange(SupportedImageExtensionsList);
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path)) return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false)
.Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase) && System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase)) .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
} }

View File

@ -103,6 +103,16 @@ namespace MediaBrowser.Controller.Providers
return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory);
} }
public IEnumerable<string> GetFilePaths(string path)
{
return _fileSystem.GetFilePaths(path);
}
public IEnumerable<string> GetFilePaths(string path, bool clearCache)
{
return _fileSystem.GetFilePaths(path);
}
public FileSystemMetadata GetFile(string path) public FileSystemMetadata GetFile(string path)
{ {
FileSystemMetadata file; FileSystemMetadata file;

View File

@ -8,9 +8,10 @@ namespace MediaBrowser.Controller.Providers
public interface IDirectoryService public interface IDirectoryService
{ {
IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path); IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path);
IEnumerable<FileSystemMetadata> GetFiles(string path);
IEnumerable<FileSystemMetadata> GetDirectories(string path); IEnumerable<FileSystemMetadata> GetDirectories(string path);
IEnumerable<FileSystemMetadata> GetFiles(string path, bool clearCache); IEnumerable<FileSystemMetadata> GetFiles(string path);
IEnumerable<string> GetFilePaths(string path);
IEnumerable<string> GetFilePaths(string path, bool clearCache);
FileSystemMetadata GetFile(string path); FileSystemMetadata GetFile(string path);
Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(string path); Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(string path);
} }

View File

@ -39,7 +39,7 @@ namespace MediaBrowser.LocalMetadata.Images
{ {
var collectionFolder = (CollectionFolder)item; var collectionFolder = (CollectionFolder)item;
return new LocalImageProvider(_fileSystem).GetImages(item, collectionFolder.PhysicalLocations, directoryService); return new LocalImageProvider(_fileSystem).GetImages(item, collectionFolder.PhysicalLocations, true, directoryService);
} }
} }
} }

View File

@ -56,7 +56,8 @@ namespace MediaBrowser.LocalMetadata.Images
if (parentPathFiles.Any(i => string.Equals(i.FullName, metadataPath, StringComparison.OrdinalIgnoreCase))) if (parentPathFiles.Any(i => string.Equals(i.FullName, metadataPath, StringComparison.OrdinalIgnoreCase)))
{ {
return GetFilesFromParentFolder(nameWithoutExtension, directoryService.GetFiles(metadataPath)); var filesInMetadataFolder = _fileSystem.GetFiles(metadataPath, BaseItem.SupportedImageExtensions, false, false);
return GetFilesFromParentFolder(nameWithoutExtension, filesInMetadataFolder);
} }
return new List<LocalImageInfo>(); return new List<LocalImageInfo>();

View File

@ -47,7 +47,7 @@ namespace MediaBrowser.LocalMetadata.Images
try try
{ {
return new LocalImageProvider(_fileSystem).GetImages(item, path, directoryService); return new LocalImageProvider(_fileSystem).GetImages(item, path, false, directoryService);
} }
catch (IOException) catch (IOException)
{ {

View File

@ -67,7 +67,7 @@ namespace MediaBrowser.LocalMetadata.Images
try try
{ {
return new LocalImageProvider(_fileSystem).GetImages(item, path, directoryService); return new LocalImageProvider(_fileSystem).GetImages(item, path, false, directoryService);
} }
catch (IOException) catch (IOException)
{ {

View File

@ -96,27 +96,37 @@ namespace MediaBrowser.LocalMetadata.Images
return list; return list;
} }
public List<LocalImageInfo> GetImages(IHasImages item, string path, IDirectoryService directoryService) public List<LocalImageInfo> GetImages(IHasImages item, string path, bool isPathInMediaFolder, IDirectoryService directoryService)
{ {
return GetImages(item, new[] { path }, directoryService); return GetImages(item, new[] { path }, isPathInMediaFolder, directoryService);
} }
public List<LocalImageInfo> GetImages(IHasImages item, IEnumerable<string> paths, IDirectoryService directoryService) public List<LocalImageInfo> GetImages(IHasImages item, IEnumerable<string> paths, bool arePathsInMediaFolders, IDirectoryService directoryService)
{ {
var files = paths.SelectMany(directoryService.GetFiles) IEnumerable<FileSystemMetadata> files;
.Where(i =>
{
var ext = i.Extension;
return !string.IsNullOrEmpty(ext) && if (arePathsInMediaFolders)
BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase); {
}) files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false));
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty)) }
.ToList(); else
{
files = paths.SelectMany(directoryService.GetFiles)
.Where(i =>
{
var ext = i.Extension;
return !string.IsNullOrEmpty(ext) &&
BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
});
}
files = files
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty));
var list = new List<LocalImageInfo>(); var list = new List<LocalImageInfo>();
PopulateImages(item, list, files, false, directoryService); PopulateImages(item, list, files.ToList(), false, directoryService);
return list; return list;
} }
@ -132,7 +142,7 @@ namespace MediaBrowser.LocalMetadata.Images
PopulateSeasonImagesFromSeriesFolder(season, images, directoryService); PopulateSeasonImagesFromSeriesFolder(season, images, directoryService);
} }
} }
var imagePrefix = item.FileNameWithoutExtension + "-"; var imagePrefix = item.FileNameWithoutExtension + "-";
var isInMixedFolder = item.DetectIsInMixedFolder(); var isInMixedFolder = item.DetectIsInMixedFolder();
@ -188,7 +198,7 @@ namespace MediaBrowser.LocalMetadata.Images
names.Insert(0, "folder"); names.Insert(0, "folder");
names.Insert(0, "poster"); names.Insert(0, "poster");
} }
// Support plex/kodi convention // Support plex/kodi convention
if (item is Series) if (item is Series)
{ {
@ -256,18 +266,7 @@ namespace MediaBrowser.LocalMetadata.Images
private void PopulateBackdropsFromExtraFanart(string path, List<LocalImageInfo> images, IDirectoryService directoryService) private void PopulateBackdropsFromExtraFanart(string path, List<LocalImageInfo> images, IDirectoryService directoryService)
{ {
var imageFiles = directoryService.GetFiles(path) var imageFiles = _fileSystem.GetFiles(path, BaseItem.SupportedImageExtensions, false, false);
.Where(i =>
{
var extension = i.Extension;
if (string.IsNullOrEmpty(extension))
{
return false;
}
return BaseItem.SupportedImageExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
});
images.AddRange(imageFiles.Select(i => new LocalImageInfo images.AddRange(imageFiles.Select(i => new LocalImageInfo
{ {

View File

@ -223,7 +223,6 @@ namespace MediaBrowser.Model.Configuration
EnableAnonymousUsageReporting = true; EnableAnonymousUsageReporting = true;
EnableAutomaticRestart = true; EnableAutomaticRestart = true;
EnableFolderView = true;
EnableUPnP = true; EnableUPnP = true;
SharingExpirationDays = 30; SharingExpirationDays = 30;

View File

@ -191,11 +191,10 @@ namespace MediaBrowser.Model.IO
/// <summary> /// <summary>
/// Gets the files. /// Gets the files.
/// </summary> /// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable&lt;FileInfo&gt;.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false); IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
IEnumerable<FileSystemMetadata> GetFiles(string path, string [] extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary> /// <summary>
/// Gets the file system entries. /// Gets the file system entries.
/// </summary> /// </summary>

View File

@ -199,7 +199,6 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
return !video.SubtitleFiles return !video.SubtitleFiles
.SequenceEqual(SubtitleResolver.GetSubtitleFiles(video, directoryService, _fileSystem, false) .SequenceEqual(SubtitleResolver.GetSubtitleFiles(video, directoryService, _fileSystem, false)
.Select(i => i.FullName)
.OrderBy(i => i), StringComparer.OrdinalIgnoreCase); .OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
} }
} }

View File

@ -662,8 +662,7 @@ namespace MediaBrowser.Providers.MediaInfo
// Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size // Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size
// Once we reach a file that is at least the minimum, return all subsequent ones // Once we reach a file that is at least the minimum, return all subsequent ones
var allVobs = _fileSystem.GetFiles(root, true) var allVobs = _fileSystem.GetFiles(root, new[] { ".vob" }, false, true)
.Where(file => string.Equals(file.Extension, ".vob", StringComparison.OrdinalIgnoreCase))
.OrderBy(i => i.FullName) .OrderBy(i => i.FullName)
.ToList(); .ToList();

View File

@ -6,8 +6,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
@ -36,11 +34,9 @@ namespace MediaBrowser.Providers.MediaInfo
var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(video.Path); var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(video.Path);
videoFileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(videoFileNameWithoutExtension); videoFileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(videoFileNameWithoutExtension);
foreach (var file in files) foreach (var fullName in files)
{ {
var fullName = file.FullName; var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(fullName);
var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(file);
fileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(fileNameWithoutExtension); fileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(fileNameWithoutExtension);
var codec = Path.GetExtension(fullName).ToLower().TrimStart('.'); var codec = Path.GetExtension(fullName).ToLower().TrimStart('.');
@ -128,7 +124,7 @@ namespace MediaBrowser.Providers.MediaInfo
} }
} }
public static IEnumerable<FileSystemMetadata> GetSubtitleFiles(Video video, IDirectoryService directoryService, IFileSystem fileSystem, bool clearCache) public static IEnumerable<string> GetSubtitleFiles(Video video, IDirectoryService directoryService, IFileSystem fileSystem, bool clearCache)
{ {
var containingPath = video.ContainingFolderPath; var containingPath = video.ContainingFolderPath;
@ -137,14 +133,15 @@ namespace MediaBrowser.Providers.MediaInfo
throw new ArgumentException(string.Format("Cannot search for items that don't have a path: {0} {1}", video.Name, video.Id)); throw new ArgumentException(string.Format("Cannot search for items that don't have a path: {0} {1}", video.Name, video.Id));
} }
var files = directoryService.GetFiles(containingPath, clearCache); var files = directoryService.GetFilePaths(containingPath, clearCache);
var videoFileNameWithoutExtension = fileSystem.GetFileNameWithoutExtension(video.Path); var videoFileNameWithoutExtension = fileSystem.GetFileNameWithoutExtension(video.Path);
return files.Where(i => return files.Where(i =>
{ {
if (!i.IsDirectory && var extension = Path.GetExtension(i);
SubtitleExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
if (SubtitleExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{ {
var fileNameWithoutExtension = fileSystem.GetFileNameWithoutExtension(i); var fileNameWithoutExtension = fileSystem.GetFileNameWithoutExtension(i);

View File

@ -436,7 +436,7 @@ namespace MediaBrowser.Providers.TV
{ {
try try
{ {
var files = _fileSystem.GetFiles(seriesDataPath) var files = _fileSystem.GetFiles(seriesDataPath, new[] { ".xml" }, true, false)
.ToList(); .ToList();
var seriesXmlFilename = preferredMetadataLanguage + ".xml"; var seriesXmlFilename = preferredMetadataLanguage + ".xml";