Merge pull request #1155 from arcticwaters/symlinks

Handle symlinks in library folders
This commit is contained in:
Luke 2015-08-15 16:41:19 -04:00
commit 8e4c9940ee
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)