Handle symlinks in library folders

pull/702/head
Andrew Schurman 9 years ago
parent ebd2f7b63d
commit 5571bf4736

@ -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))
{

@ -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)

Loading…
Cancel
Save