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/DotIgnoreIgnoreRule.cs48
-rw-r--r--Emby.Server.Implementations/Library/IgnorePatterns.cs1
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs40
3 files changed, 74 insertions, 15 deletions
diff --git a/Emby.Server.Implementations/Library/DotIgnoreIgnoreRule.cs b/Emby.Server.Implementations/Library/DotIgnoreIgnoreRule.cs
index 473ff8e1d..ef5d24c70 100644
--- a/Emby.Server.Implementations/Library/DotIgnoreIgnoreRule.cs
+++ b/Emby.Server.Implementations/Library/DotIgnoreIgnoreRule.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Text.RegularExpressions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Resolvers;
@@ -70,12 +71,55 @@ public class DotIgnoreIgnoreRule : IResolverIgnoreRule
{
// If file has content, base ignoring off the content .gitignore-style rules
var rules = ignoreFileContent.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ return CheckIgnoreRules(path, rules, isDirectory);
+ }
+
+ /// <summary>
+ /// Checks whether a path should be ignored based on an array of ignore rules.
+ /// </summary>
+ /// <param name="path">The path to check.</param>
+ /// <param name="rules">The array of ignore rules.</param>
+ /// <param name="isDirectory">Whether the path is a directory.</param>
+ /// <returns>True if the path should be ignored.</returns>
+ internal static bool CheckIgnoreRules(string path, string[] rules, bool isDirectory)
+ => CheckIgnoreRules(path, rules, isDirectory, IsWindows);
+
+ /// <summary>
+ /// Checks whether a path should be ignored based on an array of ignore rules.
+ /// </summary>
+ /// <param name="path">The path to check.</param>
+ /// <param name="rules">The array of ignore rules.</param>
+ /// <param name="isDirectory">Whether the path is a directory.</param>
+ /// <param name="normalizePath">Whether to normalize backslashes to forward slashes (for Windows paths).</param>
+ /// <returns>True if the path should be ignored.</returns>
+ internal static bool CheckIgnoreRules(string path, string[] rules, bool isDirectory, bool normalizePath)
+ {
var ignore = new Ignore.Ignore();
- ignore.Add(rules);
+
+ // Add each rule individually to catch and skip invalid patterns
+ var validRulesAdded = 0;
+ foreach (var rule in rules)
+ {
+ try
+ {
+ ignore.Add(rule);
+ validRulesAdded++;
+ }
+ catch (RegexParseException)
+ {
+ // Ignore invalid patterns
+ }
+ }
+
+ // If no valid rules were added, fall back to ignoring everything (like an empty .ignore file)
+ if (validRulesAdded == 0)
+ {
+ return true;
+ }
// Mitigate the problem of the Ignore library not handling Windows paths correctly.
// See https://github.com/jellyfin/jellyfin/issues/15484
- var pathToCheck = IsWindows ? path.NormalizePath('/') : path;
+ var pathToCheck = normalizePath ? path.NormalizePath('/') : path;
// Add trailing slash for directories to match "folder/"
if (isDirectory)
diff --git a/Emby.Server.Implementations/Library/IgnorePatterns.cs b/Emby.Server.Implementations/Library/IgnorePatterns.cs
index fe3a1ce61..5fac2f6b0 100644
--- a/Emby.Server.Implementations/Library/IgnorePatterns.cs
+++ b/Emby.Server.Implementations/Library/IgnorePatterns.cs
@@ -83,6 +83,7 @@ namespace Emby.Server.Implementations.Library
// Unix hidden files
"**/.*",
+ "**/.*/**",
// Mac - if you ever remove the above.
// "**/._*",
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 30c3e89b4..f7f5c387e 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -1058,6 +1058,7 @@ namespace Emby.Server.Implementations.Library
{
IncludeItemTypes = [BaseItemKind.MusicArtist],
Name = name,
+ UseRawName = true,
DtoOptions = options
}).Cast<MusicArtist>()
.OrderBy(i => i.IsAccessedByName ? 1 : 0)
@@ -2201,6 +2202,12 @@ namespace Emby.Server.Implementations.Library
public Task UpdateItemAsync(BaseItem item, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
=> UpdateItemsAsync([item], parent, updateReason, cancellationToken);
+ /// <inheritdoc />
+ public async Task ReattachUserDataAsync(BaseItem item, CancellationToken cancellationToken)
+ {
+ await _itemRepository.ReattachUserDataAsync(item, cancellationToken).ConfigureAwait(false);
+ }
+
public async Task RunMetadataSavers(BaseItem item, ItemUpdateType updateReason)
{
if (item.IsFileProtocol)
@@ -3194,19 +3201,7 @@ namespace Emby.Server.Implementations.Library
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
- var shortcutFilename = Path.GetFileNameWithoutExtension(path);
-
- var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
-
- while (File.Exists(lnk))
- {
- shortcutFilename += "1";
- lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
- }
-
- _fileSystem.CreateShortcut(lnk, _appHost.ReverseVirtualPath(path));
-
- RemoveContentTypeOverrides(path);
+ CreateShortcut(virtualFolderPath, pathInfo);
if (saveLibraryOptions)
{
@@ -3371,5 +3366,24 @@ namespace Emby.Server.Implementations.Library
return item is UserRootFolder || item.IsVisibleStandalone(user);
}
+
+ public void CreateShortcut(string virtualFolderPath, MediaPathInfo pathInfo)
+ {
+ var path = pathInfo.Path;
+ var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
+
+ var shortcutFilename = Path.GetFileNameWithoutExtension(path);
+
+ var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
+
+ while (File.Exists(lnk))
+ {
+ shortcutFilename += "1";
+ lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
+ }
+
+ _fileSystem.CreateShortcut(lnk, _appHost.ReverseVirtualPath(path));
+ RemoveContentTypeOverrides(path);
+ }
}
}