diff options
Diffstat (limited to 'Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs | 88 |
1 files changed, 56 insertions, 32 deletions
diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index 5c3e1dab1..59f0a9fc9 100644 --- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -22,10 +22,12 @@ namespace Emby.Server.Implementations.Library private readonly ILibraryManager _libraryManager; private readonly ILogger _logger; + private bool _ignoreDotPrefix; + /// <summary> /// Any folder named in this list will be ignored - can be added to at runtime for extensibility /// </summary> - public static readonly List<string> IgnoreFolders = new List<string> + public static readonly Dictionary<string, string> IgnoreFolders = new List<string> { "metadata", "ps3_update", @@ -41,15 +43,24 @@ namespace Emby.Server.Implementations.Library "#recycle", // Qnap - "@Recycle" + "@Recycle", + ".@__thumb", + "$RECYCLE.BIN", + "System Volume Information", + ".grab", + + // macos + ".AppleDouble" + + }.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - }; - public CoreResolutionIgnoreRule(IFileSystem fileSystem, ILibraryManager libraryManager, ILogger logger) { _fileSystem = fileSystem; _libraryManager = libraryManager; _logger = logger; + + _ignoreDotPrefix = Environment.OSVersion.Platform != PlatformID.Win32NT; } /// <summary> @@ -67,46 +78,48 @@ namespace Emby.Server.Implementations.Library } var filename = fileInfo.Name; - var isHidden = fileInfo.IsHidden; var path = fileInfo.FullName; // Handle mac .DS_Store // https://github.com/MediaBrowser/MediaBrowser/issues/427 - if (filename.IndexOf("._", StringComparison.OrdinalIgnoreCase) == 0) + if (_ignoreDotPrefix) { - return true; - } - - // Ignore hidden files and folders - if (isHidden) - { - if (parent == null) + if (filename.IndexOf('.') == 0) { - var parentFolderName = Path.GetFileName(_fileSystem.GetDirectoryName(path)); - - if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - if (string.Equals(parentFolderName, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - } - - // Sometimes these are marked hidden - if (_fileSystem.IsRootPath(path)) - { - return false; + return true; } - - return true; } + // Ignore hidden files and folders + //if (fileInfo.IsHidden) + //{ + // if (parent == null) + // { + // var parentFolderName = Path.GetFileName(_fileSystem.GetDirectoryName(path)); + + // if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase)) + // { + // return false; + // } + // if (string.Equals(parentFolderName, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase)) + // { + // return false; + // } + // } + + // // Sometimes these are marked hidden + // if (_fileSystem.IsRootPath(path)) + // { + // return false; + // } + + // return true; + //} + if (fileInfo.IsDirectory) { // Ignore any folders in our list - if (IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase)) + if (IgnoreFolders.ContainsKey(filename)) { return true; } @@ -141,6 +154,17 @@ namespace Emby.Server.Implementations.Library return true; } } + + // Ignore samples + var sampleFilename = " " + filename.Replace(".", " ", StringComparison.OrdinalIgnoreCase) + .Replace("-", " ", StringComparison.OrdinalIgnoreCase) + .Replace("_", " ", StringComparison.OrdinalIgnoreCase) + .Replace("!", " ", StringComparison.OrdinalIgnoreCase); + + if (sampleFilename.IndexOf(" sample ", StringComparison.OrdinalIgnoreCase) != -1) + { + return true; + } } return false; |
