| | 1 | | using System; |
| | 2 | | using System.IO; |
| | 3 | | using Emby.Naming.Audio; |
| | 4 | | using Emby.Naming.Common; |
| | 5 | | using MediaBrowser.Controller; |
| | 6 | | using MediaBrowser.Controller.Entities; |
| | 7 | | using MediaBrowser.Controller.Resolvers; |
| | 8 | | using MediaBrowser.Model.IO; |
| | 9 | |
|
| | 10 | | namespace Emby.Server.Implementations.Library |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Provides the core resolver ignore rules. |
| | 14 | | /// </summary> |
| | 15 | | public class CoreResolutionIgnoreRule : IResolverIgnoreRule |
| | 16 | | { |
| | 17 | | private readonly NamingOptions _namingOptions; |
| | 18 | | private readonly IServerApplicationPaths _serverApplicationPaths; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Initializes a new instance of the <see cref="CoreResolutionIgnoreRule"/> class. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="namingOptions">The naming options.</param> |
| | 24 | | /// <param name="serverApplicationPaths">The server application paths.</param> |
| | 25 | | public CoreResolutionIgnoreRule(NamingOptions namingOptions, IServerApplicationPaths serverApplicationPaths) |
| | 26 | | { |
| 26 | 27 | | _namingOptions = namingOptions; |
| 26 | 28 | | _serverApplicationPaths = serverApplicationPaths; |
| 26 | 29 | | } |
| | 30 | |
|
| | 31 | | /// <inheritdoc /> |
| | 32 | | public bool ShouldIgnore(FileSystemMetadata fileInfo, BaseItem? parent) |
| | 33 | | { |
| | 34 | | // Don't ignore application folders |
| 105 | 35 | | if (fileInfo.FullName.Contains(_serverApplicationPaths.RootFolderPath, StringComparison.InvariantCulture)) |
| | 36 | | { |
| 94 | 37 | | return false; |
| | 38 | | } |
| | 39 | |
|
| | 40 | | // Don't ignore top level folders |
| 11 | 41 | | if (fileInfo.IsDirectory |
| 11 | 42 | | && (parent is AggregateFolder || (parent?.IsTopParent ?? false))) |
| | 43 | | { |
| 3 | 44 | | return false; |
| | 45 | | } |
| | 46 | |
|
| 8 | 47 | | if (IgnorePatterns.ShouldIgnore(fileInfo.FullName)) |
| | 48 | | { |
| 1 | 49 | | return true; |
| | 50 | | } |
| | 51 | |
|
| 7 | 52 | | if (parent is null) |
| | 53 | | { |
| 1 | 54 | | return false; |
| | 55 | | } |
| | 56 | |
|
| 6 | 57 | | if (fileInfo.IsDirectory) |
| | 58 | | { |
| | 59 | | // Ignore extras for unsupported types |
| 3 | 60 | | return _namingOptions.AllExtrasTypesFolderNames.ContainsKey(fileInfo.Name) |
| 3 | 61 | | && parent is not UserRootFolder; |
| | 62 | | } |
| | 63 | |
|
| | 64 | | // Don't resolve theme songs |
| 3 | 65 | | return Path.GetFileNameWithoutExtension(fileInfo.Name.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringCom |
| 3 | 66 | | && AudioFileParser.IsAudioFile(fileInfo.Name, _namingOptions); |
| | 67 | | } |
| | 68 | | } |
| | 69 | | } |