Handle symlinks in library folders

This commit is contained in:
Andrew Schurman 2015-08-15 13:01:40 -07:00
parent ebd2f7b63d
commit 5571bf4736
2 changed files with 6 additions and 3 deletions

View File

@ -221,7 +221,9 @@ namespace MediaBrowser.Api
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request)
{
var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos().Where(i =>
// using EnumerateFileSystemInfos doesn't handle reparse points (symlinks)
var entries = new DirectoryInfo(request.Path).EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
.Concat<FileSystemInfo>(new DirectoryInfo(request.Path).EnumerateFiles("*", SearchOption.TopDirectoryOnly)).Where(i =>
{
if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
{

View File

@ -58,8 +58,9 @@ namespace MediaBrowser.Controller.Providers
try
{
var list = new DirectoryInfo(path)
.EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly);
// using EnumerateFileSystemInfos doesn't handle reparse points (symlinks)
var list = new DirectoryInfo(path).EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
.Concat<FileSystemInfo>(new DirectoryInfo(path).EnumerateFiles("*", SearchOption.TopDirectoryOnly));
// Seeing dupes on some users file system for some reason
foreach (var item in list)