Only add internal files if the internal metadata path exists
Signed-off-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
parent
e26446f9c0
commit
40e413d575
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
|
@ -78,5 +79,9 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
return filePaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool PathExists(string path)
|
||||||
|
=> Directory.Exists(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,12 @@ namespace MediaBrowser.Controller.Providers
|
||||||
IReadOnlyList<string> GetFilePaths(string path);
|
IReadOnlyList<string> GetFilePaths(string path);
|
||||||
|
|
||||||
IReadOnlyList<string> GetFilePaths(string path, bool clearCache, bool sort = false);
|
IReadOnlyList<string> GetFilePaths(string path, bool clearCache, bool sort = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Does the path exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns>Whether the path exists.</returns>
|
||||||
|
bool PathExists(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
|
|
||||||
// Check if video folder exists
|
// Check if video folder exists
|
||||||
string folder = video.ContainingFolderPath;
|
string folder = video.ContainingFolderPath;
|
||||||
if (!Directory.Exists(folder))
|
if (!directoryService.PathExists(folder))
|
||||||
{
|
{
|
||||||
return Array.Empty<ExternalPathParserResult>();
|
return Array.Empty<ExternalPathParserResult>();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,11 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
var externalPathInfos = new List<ExternalPathParserResult>();
|
var externalPathInfos = new List<ExternalPathParserResult>();
|
||||||
|
|
||||||
var files = directoryService.GetFilePaths(folder, clearCache).ToList();
|
var files = directoryService.GetFilePaths(folder, clearCache).ToList();
|
||||||
|
var internalMetadataPath = video.GetInternalMetadataPath();
|
||||||
|
if (directoryService.PathExists(internalMetadataPath))
|
||||||
|
{
|
||||||
files.AddRange(directoryService.GetFilePaths(video.GetInternalMetadataPath(), clearCache));
|
files.AddRange(directoryService.GetFilePaths(video.GetInternalMetadataPath(), clearCache));
|
||||||
|
}
|
||||||
|
|
||||||
if (!files.Any())
|
if (!files.Any())
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,6 +150,8 @@ public class MediaInfoResolverTests
|
||||||
var directoryService = new Mock<IDirectoryService>(MockBehavior.Strict);
|
var directoryService = new Mock<IDirectoryService>(MockBehavior.Strict);
|
||||||
directoryService.Setup(ds => ds.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>()))
|
directoryService.Setup(ds => ds.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>()))
|
||||||
.Returns(Array.Empty<string>());
|
.Returns(Array.Empty<string>());
|
||||||
|
directoryService.Setup(ds => ds.PathExists(It.IsAny<string>()))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
var mediaEncoder = Mock.Of<IMediaEncoder>(MockBehavior.Strict);
|
var mediaEncoder = Mock.Of<IMediaEncoder>(MockBehavior.Strict);
|
||||||
|
|
||||||
|
@ -299,6 +301,10 @@ public class MediaInfoResolverTests
|
||||||
.Returns(files);
|
.Returns(files);
|
||||||
directoryService.Setup(ds => ds.GetFilePaths(It.IsRegex(MetadataDirectoryRegex), It.IsAny<bool>(), It.IsAny<bool>()))
|
directoryService.Setup(ds => ds.GetFilePaths(It.IsRegex(MetadataDirectoryRegex), It.IsAny<bool>(), It.IsAny<bool>()))
|
||||||
.Returns(Array.Empty<string>());
|
.Returns(Array.Empty<string>());
|
||||||
|
directoryService.Setup(ds => ds.PathExists(It.IsRegex(MetadataDirectoryRegex)))
|
||||||
|
.Returns(true);
|
||||||
|
directoryService.Setup(ds => ds.PathExists(It.IsRegex(VideoDirectoryRegex)))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
List<MediaStream> GenerateMediaStreams()
|
List<MediaStream> GenerateMediaStreams()
|
||||||
{
|
{
|
||||||
|
@ -370,6 +376,11 @@ public class MediaInfoResolverTests
|
||||||
.Returns(Array.Empty<string>());
|
.Returns(Array.Empty<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directoryService.Setup(ds => ds.PathExists(It.IsRegex(MetadataDirectoryRegex)))
|
||||||
|
.Returns(true);
|
||||||
|
directoryService.Setup(ds => ds.PathExists(It.IsRegex(VideoDirectoryRegex)))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
return directoryService.Object;
|
return directoryService.Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user