Remove file extension filter and fix build
This commit is contained in:
parent
58b9e5af79
commit
28c2ac9cc0
|
@ -2700,7 +2700,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
var current = fileSystemChildren[i];
|
var current = fileSystemChildren[i];
|
||||||
if (current.IsDirectory && _namingOptions.AllExtrasTypesFolderNames.ContainsKey(current.Name))
|
if (current.IsDirectory && _namingOptions.AllExtrasTypesFolderNames.ContainsKey(current.Name))
|
||||||
{
|
{
|
||||||
var filesInSubFolder = _fileSystem.GetFiles(current.FullName, _namingOptions.VideoFileExtensions, false, false);
|
var filesInSubFolder = _fileSystem.GetFiles(current.FullName, null, false, false);
|
||||||
foreach (var file in filesInSubFolder)
|
foreach (var file in filesInSubFolder)
|
||||||
{
|
{
|
||||||
if (!_extraResolver.TryGetExtraTypeForOwner(file.FullName, ownerVideoInfo, out var extraType))
|
if (!_extraResolver.TryGetExtraTypeForOwner(file.FullName, ownerVideoInfo, out var extraType))
|
||||||
|
|
|
@ -6,14 +6,14 @@ using MediaBrowser.Controller.Entities;
|
||||||
namespace Emby.Server.Implementations.Library.Resolvers
|
namespace Emby.Server.Implementations.Library.Resolvers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves a Path into a Video or Video subclass.
|
/// Resolves a Path into an instance of the <see cref="Video"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of item to resolve.</typeparam>
|
/// <typeparam name="T">The type of item to resolve.</typeparam>
|
||||||
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
||||||
where T : Video, new()
|
where T : Video, new()
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GenericVideoResolver"/> class.
|
/// Initializes a new instance of the <see cref="GenericVideoResolver{T}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="namingOptions">The naming options.</param>
|
/// <param name="namingOptions">The naming options.</param>
|
||||||
public GenericVideoResolver(NamingOptions namingOptions)
|
public GenericVideoResolver(NamingOptions namingOptions)
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class FindExtrasTests
|
||||||
Name = "some trailer.mkv",
|
Name = "some trailer.mkv",
|
||||||
IsDirectory = false
|
IsDirectory = false
|
||||||
}
|
}
|
||||||
});
|
}).Verifiable();
|
||||||
|
|
||||||
_fileSystemMock.Setup(f => f.GetFiles(
|
_fileSystemMock.Setup(f => f.GetFiles(
|
||||||
"/movies/Up/behind the scenes",
|
"/movies/Up/behind the scenes",
|
||||||
|
@ -123,7 +123,7 @@ public class FindExtrasTests
|
||||||
Name = "the making of Up.mkv",
|
Name = "the making of Up.mkv",
|
||||||
IsDirectory = false
|
IsDirectory = false
|
||||||
}
|
}
|
||||||
});
|
}).Verifiable();
|
||||||
|
|
||||||
_fileSystemMock.Setup(f => f.GetFiles(
|
_fileSystemMock.Setup(f => f.GetFiles(
|
||||||
"/movies/Up/theme-music",
|
"/movies/Up/theme-music",
|
||||||
|
@ -138,17 +138,18 @@ public class FindExtrasTests
|
||||||
Name = "theme2.mp3",
|
Name = "theme2.mp3",
|
||||||
IsDirectory = false
|
IsDirectory = false
|
||||||
}
|
}
|
||||||
});
|
}).Verifiable();
|
||||||
|
|
||||||
var files = paths.Select(p => new FileSystemMetadata
|
var files = paths.Select(p => new FileSystemMetadata
|
||||||
{
|
{
|
||||||
FullName = p,
|
FullName = p,
|
||||||
Name = Path.GetFileName(p),
|
Name = Path.GetFileName(p),
|
||||||
IsDirectory = string.IsNullOrEmpty(Path.GetExtension(p))
|
IsDirectory = !Path.HasExtension(p)
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var extras = _libraryManager.FindExtras(owner, files, new DirectoryService(_fileSystemMock.Object)).OrderBy(e => e.ExtraType).ToList();
|
var extras = _libraryManager.FindExtras(owner, files, new DirectoryService(_fileSystemMock.Object)).OrderBy(e => e.ExtraType).ToList();
|
||||||
|
|
||||||
|
_fileSystemMock.Verify();
|
||||||
Assert.Equal(6, extras.Count);
|
Assert.Equal(6, extras.Count);
|
||||||
Assert.Equal(ExtraType.Trailer, extras[0].ExtraType);
|
Assert.Equal(ExtraType.Trailer, extras[0].ExtraType);
|
||||||
Assert.Equal(typeof(Trailer), extras[0].GetType());
|
Assert.Equal(typeof(Trailer), extras[0].GetType());
|
||||||
|
@ -215,6 +216,46 @@ public class FindExtrasTests
|
||||||
Assert.Equal("/movies/Up/trailer.mkv", extras[0].Path);
|
Assert.Equal("/movies/Up/trailer.mkv", extras[0].Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void FindExtras_WrongExtensions_FindsNoExtras()
|
||||||
|
{
|
||||||
|
var owner = new Movie { Name = "Up", Path = "/movies/Up/Up.mkv" };
|
||||||
|
var paths = new List<string>
|
||||||
|
{
|
||||||
|
"/movies/Up/Up.mkv",
|
||||||
|
"/movies/Up/trailer.noext",
|
||||||
|
"/movies/Up/theme.png",
|
||||||
|
"/movies/Up/trailers"
|
||||||
|
};
|
||||||
|
|
||||||
|
var files = paths.Select(p => new FileSystemMetadata
|
||||||
|
{
|
||||||
|
FullName = p,
|
||||||
|
Name = Path.GetFileName(p),
|
||||||
|
IsDirectory = !Path.HasExtension(p)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
_fileSystemMock.Setup(f => f.GetFiles(
|
||||||
|
"/movies/Up/trailers",
|
||||||
|
It.IsAny<string[]>(),
|
||||||
|
false,
|
||||||
|
false))
|
||||||
|
.Returns(new List<FileSystemMetadata>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
FullName = "/movies/Up/trailers/trailer.jpg",
|
||||||
|
Name = "trailer.jpg",
|
||||||
|
IsDirectory = false
|
||||||
|
}
|
||||||
|
}).Verifiable();
|
||||||
|
|
||||||
|
var extras = _libraryManager.FindExtras(owner, files, new DirectoryService(_fileSystemMock.Object)).OrderBy(e => e.ExtraType).ToList();
|
||||||
|
|
||||||
|
_fileSystemMock.Verify();
|
||||||
|
Assert.Empty(extras);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FindExtras_SeriesWithTrailers_FindsCorrectExtras()
|
public void FindExtras_SeriesWithTrailers_FindsCorrectExtras()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user