From 7987e64d3875ac0e175224d81d6815596b9dfba9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 30 Mar 2017 13:56:32 -0400 Subject: [PATCH 1/3] add new file method overloads --- BDInfo/BDROM.cs | 11 +++++-- .../IO/ManagedFileSystem.cs | 32 +++++++++++++++++-- .../FileOrganization/TvFolderOrganizer.cs | 6 ++-- .../Library/LibraryManager.cs | 4 +-- MediaBrowser.Model/IO/IFileSystem.cs | 1 + 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index d42e381daa..123d1afe54 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -137,19 +137,19 @@ namespace BDInfo } if (DirectoryBDJO != null && - _fileSystem.GetFiles(DirectoryBDJO.FullName).Any()) + _fileSystem.GetFilePaths(DirectoryBDJO.FullName).Any()) { IsBDJava = true; } if (DirectorySNP != null && - GetFiles(DirectorySNP.FullName, ".mnv").Any()) + GetFilePaths(DirectorySNP.FullName, ".mnv").Any()) { IsPSP = true; } if (DirectorySSIF != null && - _fileSystem.GetFiles(DirectorySSIF.FullName).Any()) + _fileSystem.GetFilePaths(DirectorySSIF.FullName).Any()) { Is3D = true; } @@ -209,6 +209,11 @@ namespace BDInfo return _fileSystem.GetFiles(path, new[] { extension }, false, false); } + private IEnumerable GetFilePaths(string path, string extension) + { + return _fileSystem.GetFilePaths(path, new[] { extension }, false, false); + } + public void Scan() { List errorStreamClipFiles = new List(); diff --git a/Emby.Common.Implementations/IO/ManagedFileSystem.cs b/Emby.Common.Implementations/IO/ManagedFileSystem.cs index ed940eca5f..4d7a868211 100644 --- a/Emby.Common.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Common.Implementations/IO/ManagedFileSystem.cs @@ -662,7 +662,7 @@ namespace Emby.Common.Implementations.IO public IEnumerable GetFiles(string path, bool recursive = false) { - return GetFiles(path, null, true, recursive); + return GetFiles(path, null, false, recursive); } public IEnumerable GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) @@ -790,9 +790,37 @@ namespace Emby.Common.Implementations.IO } public IEnumerable GetFilePaths(string path, bool recursive = false) + { + return GetFilePaths(path, null, false, recursive); + } + + public IEnumerable GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; - return Directory.EnumerateFiles(path, "*", 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 Directory.EnumerateFiles(path, "*" + extensions[0], searchOption); + } + + var files = Directory.EnumerateFiles(path, "*", searchOption); + + if (extensions != null && extensions.Length > 0) + { + files = files.Where(i => + { + var ext = Path.GetExtension(i); + if (ext == null) + { + return false; + } + return extensions.Contains(ext, StringComparer.OrdinalIgnoreCase); + }); + } + + return files; } public IEnumerable GetFileSystemEntryPaths(string path, bool recursive = false) diff --git a/Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs index c885f03ac4..2cbf2613ec 100644 --- a/Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs +++ b/Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs @@ -178,18 +178,18 @@ namespace Emby.Server.Implementations.FileOrganization /// The extensions. private void DeleteLeftOverFiles(string path, IEnumerable extensions) { - var eligibleFiles = _fileSystem.GetFiles(path, extensions.ToArray(), false, true) + var eligibleFiles = _fileSystem.GetFilePaths(path, extensions.ToArray(), false, true) .ToList(); foreach (var file in eligibleFiles) { try { - _fileSystem.DeleteFile(file.FullName); + _fileSystem.DeleteFile(file); } catch (Exception ex) { - _logger.ErrorException("Error deleting file {0}", ex, file.FullName); + _logger.ErrorException("Error deleting file {0}", ex, file); } } } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 17e6786153..dbb0160a53 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1255,9 +1255,9 @@ namespace Emby.Server.Implementations.Library private string GetCollectionType(string path) { - return _fileSystem.GetFiles(path, new[] { ".collection" }, true, false) + return _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false) .Select(i => _fileSystem.GetFileNameWithoutExtension(i)) - .FirstOrDefault(); + .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); } /// diff --git a/MediaBrowser.Model/IO/IFileSystem.cs b/MediaBrowser.Model/IO/IFileSystem.cs index 180d2f227a..e791503ab0 100644 --- a/MediaBrowser.Model/IO/IFileSystem.cs +++ b/MediaBrowser.Model/IO/IFileSystem.cs @@ -298,6 +298,7 @@ namespace MediaBrowser.Model.IO /// if set to true [recursive]. /// IEnumerable<System.String>. IEnumerable GetFilePaths(string path, bool recursive = false); + IEnumerable GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive); /// /// Gets the file system entry paths. From 514927291c5d2f348e286f0778ab4ae6e98cccdd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 30 Mar 2017 13:58:38 -0400 Subject: [PATCH 2/3] fix hd homerun host stream ids --- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 8fa1bbe231..0a21603eed 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -382,7 +382,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { id = "native"; } - id += "_" + url.GetMD5().ToString("N"); + id += "_" + channelId.GetMD5().ToString("N") + "_" + url.GetMD5().ToString("N"); var mediaSource = new MediaSourceInfo { From 46646b95fde4701e9a879f11e66ad461f805a6a4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 30 Mar 2017 14:03:16 -0400 Subject: [PATCH 3/3] 3.2.10.1 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index d2454d0886..0112684be2 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.9.3")] +[assembly: AssemblyVersion("3.2.10.1")]