mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-11 00:32:52 +01:00
Add .gitignore style ignoring (#13906)
This commit is contained in:
@@ -649,10 +649,11 @@ namespace Emby.Server.Implementations.Library
|
||||
args.FileSystemChildren = files;
|
||||
}
|
||||
|
||||
// Check to see if we should resolve based on our contents
|
||||
if (args.IsDirectory && !ShouldResolvePathContents(args))
|
||||
// Filter content based on ignore rules
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
return null;
|
||||
var filtered = args.GetActualFileSystemChildren().ToArray();
|
||||
args.FileSystemChildren = filtered ?? [];
|
||||
}
|
||||
|
||||
return ResolveItem(args, resolvers);
|
||||
@@ -683,17 +684,6 @@ namespace Emby.Server.Implementations.Library
|
||||
return newList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a path should be ignored based on its contents - called after the contents have been read.
|
||||
/// </summary>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private static bool ShouldResolvePathContents(ItemResolveArgs args)
|
||||
{
|
||||
// Ignore any folders containing a file called .ignore
|
||||
return !args.ContainsFileSystemEntryByName(".ignore");
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, CollectionType? collectionType = null)
|
||||
{
|
||||
return ResolvePaths(files, directoryService, parent, libraryOptions, collectionType, EntityResolvers);
|
||||
@@ -2724,16 +2714,18 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public IEnumerable<BaseItem> FindExtras(BaseItem owner, IReadOnlyList<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
|
||||
{
|
||||
// Apply .ignore rules
|
||||
var filtered = fileSystemChildren.Where(c => !DotIgnoreIgnoreRule.IsIgnored(c, owner)).ToList();
|
||||
var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions, libraryRoot: owner.ContainingFolderPath);
|
||||
if (ownerVideoInfo is null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var count = fileSystemChildren.Count;
|
||||
var count = filtered.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var current = fileSystemChildren[i];
|
||||
var current = filtered[i];
|
||||
if (current.IsDirectory && _namingOptions.AllExtrasTypesFolderNames.ContainsKey(current.Name))
|
||||
{
|
||||
var filesInSubFolder = _fileSystem.GetFiles(current.FullName, null, false, false);
|
||||
|
||||
Reference in New Issue
Block a user