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> /// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request) 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)) if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
{ {

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

Loading…
Cancel
Save