aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library')
-rw-r--r--Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs12
-rw-r--r--Emby.Server.Implementations/Library/IgnorePatterns.cs44
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs29
3 files changed, 69 insertions, 16 deletions
diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index e140009ea..77b2c0a69 100644
--- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
@@ -13,19 +14,28 @@ namespace Emby.Server.Implementations.Library
public class CoreResolutionIgnoreRule : IResolverIgnoreRule
{
private readonly ILibraryManager _libraryManager;
+ private readonly IServerApplicationPaths _serverApplicationPaths;
/// <summary>
/// Initializes a new instance of the <see cref="CoreResolutionIgnoreRule"/> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
- public CoreResolutionIgnoreRule(ILibraryManager libraryManager)
+ /// <param name="serverApplicationPaths">The server application paths.</param>
+ public CoreResolutionIgnoreRule(ILibraryManager libraryManager, IServerApplicationPaths serverApplicationPaths)
{
_libraryManager = libraryManager;
+ _serverApplicationPaths = serverApplicationPaths;
}
/// <inheritdoc />
public bool ShouldIgnore(FileSystemMetadata fileInfo, BaseItem parent)
{
+ // Don't ignore application folders
+ if (fileInfo.FullName.Contains(_serverApplicationPaths.RootFolderPath, StringComparison.InvariantCulture))
+ {
+ return false;
+ }
+
// Don't ignore top level folders
if (fileInfo.IsDirectory && parent is AggregateFolder)
{
diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs
index 8c4098948..6e6ef1359 100644
--- a/Emby.Server.Implementations/Library/IgnorePatterns.cs
+++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs
@@ -1,3 +1,6 @@
+#nullable enable
+
+using System;
using System.Linq;
using DotNet.Globbing;
@@ -11,7 +14,7 @@ namespace Emby.Server.Implementations.Library
/// <summary>
/// Files matching these glob patterns will be ignored.
/// </summary>
- public static readonly string[] Patterns = new string[]
+ private static readonly string[] _patterns =
{
"**/small.jpg",
"**/albumart.jpg",
@@ -19,32 +22,51 @@ namespace Emby.Server.Implementations.Library
// Directories
"**/metadata/**",
+ "**/metadata",
"**/ps3_update/**",
+ "**/ps3_update",
"**/ps3_vprm/**",
+ "**/ps3_vprm",
"**/extrafanart/**",
+ "**/extrafanart",
"**/extrathumbs/**",
+ "**/extrathumbs",
"**/.actors/**",
+ "**/.actors",
"**/.wd_tv/**",
+ "**/.wd_tv",
"**/lost+found/**",
+ "**/lost+found",
// WMC temp recording directories that will constantly be written to
"**/TempRec/**",
+ "**/TempRec",
"**/TempSBE/**",
+ "**/TempSBE",
// Synology
"**/eaDir/**",
+ "**/eaDir",
"**/@eaDir/**",
+ "**/@eaDir",
"**/#recycle/**",
+ "**/#recycle",
// Qnap
"**/@Recycle/**",
+ "**/@Recycle",
"**/.@__thumb/**",
+ "**/.@__thumb",
"**/$RECYCLE.BIN/**",
+ "**/$RECYCLE.BIN",
"**/System Volume Information/**",
+ "**/System Volume Information",
"**/.grab/**",
+ "**/.grab",
// Unix hidden files and directories
"**/.*/**",
+ "**/.*",
// thumbs.db
"**/thumbs.db",
@@ -56,19 +78,31 @@ namespace Emby.Server.Implementations.Library
private static readonly GlobOptions _globOptions = new GlobOptions
{
- Evaluation = {
+ Evaluation =
+ {
CaseInsensitive = true
}
};
- private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
+ private static readonly Glob[] _globs = _patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
/// <summary>
/// Returns true if the supplied path should be ignored.
/// </summary>
- public static bool ShouldIgnore(string path)
+ /// <param name="path">The path to test.</param>
+ /// <returns>Whether to ignore the path.</returns>
+ public static bool ShouldIgnore(ReadOnlySpan<char> path)
{
- return _globs.Any(g => g.IsMatch(path));
+ int len = _globs.Length;
+ for (int i = 0; i < len; i++)
+ {
+ if (_globs[i].IsMatch(path))
+ {
+ return true;
+ }
+ }
+
+ return false;
}
}
}
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 6a20a015a..77d44e131 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -514,8 +514,8 @@ namespace Emby.Server.Implementations.Library
return key.GetMD5();
}
- public BaseItem ResolvePath(FileSystemMetadata fileInfo, Folder parent = null, bool allowIgnorePath = true)
- => ResolvePath(fileInfo, new DirectoryService(_fileSystem), null, parent, allowIgnorePath: allowIgnorePath);
+ public BaseItem ResolvePath(FileSystemMetadata fileInfo, Folder parent = null)
+ => ResolvePath(fileInfo, new DirectoryService(_fileSystem), null, parent);
private BaseItem ResolvePath(
FileSystemMetadata fileInfo,
@@ -523,8 +523,7 @@ namespace Emby.Server.Implementations.Library
IItemResolver[] resolvers,
Folder parent = null,
string collectionType = null,
- LibraryOptions libraryOptions = null,
- bool allowIgnorePath = true)
+ LibraryOptions libraryOptions = null)
{
if (fileInfo == null)
{
@@ -548,7 +547,7 @@ namespace Emby.Server.Implementations.Library
};
// Return null if ignore rules deem that we should do so
- if (allowIgnorePath && IgnoreFile(args.FileInfo, args.Parent))
+ if (IgnoreFile(args.FileInfo, args.Parent))
{
return null;
}
@@ -713,7 +712,7 @@ namespace Emby.Server.Implementations.Library
Directory.CreateDirectory(rootFolderPath);
var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ??
- ((Folder) ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath), allowIgnorePath: false))
+ ((Folder) ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath)))
.DeepCopy<Folder, AggregateFolder>();
// In case program data folder was moved
@@ -795,7 +794,7 @@ namespace Emby.Server.Implementations.Library
if (tmpItem == null)
{
_logger.LogDebug("Creating new userRootFolder with DeepCopy");
- tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath), allowIgnorePath: false)).DeepCopy<Folder, UserRootFolder>();
+ tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy<Folder, UserRootFolder>();
}
// In case program data folder was moved
@@ -1894,9 +1893,19 @@ namespace Emby.Server.Implementations.Library
}
}
- ImageDimensions size = _imageProcessor.GetImageDimensions(item, image);
- image.Width = size.Width;
- image.Height = size.Height;
+ try
+ {
+ ImageDimensions size = _imageProcessor.GetImageDimensions(item, image);
+ image.Width = size.Width;
+ image.Height = size.Height;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Cannnot get image dimensions for {0}", image.Path);
+ image.Width = 0;
+ image.Height = 0;
+ continue;
+ }
try
{