mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
update file system methods
This commit is contained in:
@@ -225,8 +225,8 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||
}
|
||||
}
|
||||
|
||||
var shortcutFiles = Directory
|
||||
.EnumerateFiles(collection.Path, "*", SearchOption.TopDirectoryOnly)
|
||||
var shortcutFiles = _fileSystem
|
||||
.GetFilePaths(collection.Path)
|
||||
.Where(i => _fileSystem.IsShortcut(i))
|
||||
.ToList();
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||
|
||||
try
|
||||
{
|
||||
return Directory
|
||||
.EnumerateFiles(path, "*", SearchOption.AllDirectories)
|
||||
return _fileSystem
|
||||
.GetFilePaths(path, true)
|
||||
.Where(i => string.Equals(Path.GetFileName(i), "device.json", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList()
|
||||
.Select(i =>
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
if (!string.IsNullOrWhiteSpace(originalFilenameWithoutExtension) && !string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
// Get all related files, e.g. metadata, images, etc
|
||||
var files = Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly)
|
||||
var files = _fileSystem.GetFilePaths(directory)
|
||||
.Where(i => (Path.GetFileNameWithoutExtension(i) ?? string.Empty).StartsWith(originalFilenameWithoutExtension, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
|
||||
try
|
||||
{
|
||||
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
|
||||
var filesOfOtherExtensions = _fileSystem.GetFilePaths(folder)
|
||||
.Where(i => _libraryManager.IsVideoFile(i) && string.Equals(_fileSystem.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
episodePaths.AddRange(filesOfOtherExtensions);
|
||||
|
||||
@@ -175,12 +175,12 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var d in Directory.EnumerateDirectories(path))
|
||||
foreach (var d in _fileSystem.GetDirectoryPaths(path))
|
||||
{
|
||||
DeleteEmptyFolders(d);
|
||||
}
|
||||
|
||||
var entries = Directory.EnumerateFileSystemEntries(path);
|
||||
var entries = _fileSystem.GetFileSystemEntryPaths(path);
|
||||
|
||||
if (!entries.Any())
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.IO;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Intros
|
||||
{
|
||||
@@ -25,14 +26,16 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly IConfigurationManager _serverConfig;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public DefaultIntroProvider(ISecurityManager security, IChannelManager channelManager, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager)
|
||||
public DefaultIntroProvider(ISecurityManager security, IChannelManager channelManager, ILocalizationManager localization, IConfigurationManager serverConfig, ILibraryManager libraryManager, IFileSystem fileSystem)
|
||||
{
|
||||
_security = security;
|
||||
_channelManager = channelManager;
|
||||
_localization = localization;
|
||||
_serverConfig = serverConfig;
|
||||
_libraryManager = libraryManager;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user)
|
||||
@@ -232,7 +235,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
return Directory.EnumerateFiles(options.CustomIntroPath, "*", SearchOption.AllDirectories)
|
||||
return _fileSystem.GetFilePaths(options.CustomIntroPath, true)
|
||||
.Where(_libraryManager.IsVideoFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||
|
||||
var protocol = MediaProtocol.File;
|
||||
|
||||
var inputPath = MediaEncoderHelpers.GetInputArgument(video.Path, protocol, null, video.PlayableStreamFileNames);
|
||||
var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -194,7 +194,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||
|
||||
try
|
||||
{
|
||||
return Directory.EnumerateFiles(path)
|
||||
return _fileSystem.GetFilePaths(path)
|
||||
.ToList();
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
|
||||
Reference in New Issue
Block a user