improve smb support

This commit is contained in:
Luke Pulverenti
2017-05-04 14:14:45 -04:00
parent 53024bd149
commit 696a6b34ea
80 changed files with 256 additions and 151 deletions

View File

@@ -288,7 +288,7 @@ namespace MediaBrowser.Controller.Entities
return Path;
}
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
}
@@ -1917,7 +1917,7 @@ namespace MediaBrowser.Controller.Entities
{
var allFiles = ImageInfos
.Where(i => i.IsLocalFile)
.Select(i => System.IO.Path.GetDirectoryName(i.Path))
.Select(i => FileSystem.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase)
.SelectMany(directoryService.GetFilePaths)
.ToList();
@@ -2092,7 +2092,7 @@ namespace MediaBrowser.Controller.Entities
var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList();
extensions.AddRange(SupportedImageExtensionsList);
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false)
return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false)
.Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
.ToList();
}

View File

@@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities
.SelectMany(c => c.LinkedChildren)
.ToList();
var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer());
var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer(FileSystem));
LinkedChildren = linkedChildren;
@@ -332,13 +332,13 @@ namespace MediaBrowser.Controller.Entities
.OfType<Folder>()
.ToList();
return PhysicalLocations.Where(i => !string.Equals(i, Path, StringComparison.OrdinalIgnoreCase)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id);
return PhysicalLocations.Where(i => !FileSystem.AreEqual(i, Path)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id);
}
private IEnumerable<Folder> GetPhysicalParents(string path, List<Folder> rootChildren)
{
var result = rootChildren
.Where(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase))
.Where(i => FileSystem.AreEqual(i.Path, path))
.ToList();
if (result.Count == 0)

View File

@@ -640,7 +640,7 @@ namespace MediaBrowser.Controller.Entities
return true;
}
path = System.IO.Path.GetDirectoryName(path);
path = FileSystem.GetDirectoryName(path);
}
return allLibraryPaths.Any(i => ContainsPath(i, originalPath));
@@ -1206,11 +1206,17 @@ namespace MediaBrowser.Controller.Entities
return GetLinkedChildren();
}
var locations = user.RootFolder
.Children
if (LinkedChildren.Count == 0)
{
return new List<BaseItem>();
}
var allUserRootChildren = user.RootFolder.Children.OfType<Folder>().ToList();
var collectionFolderIds = allUserRootChildren
.OfType<CollectionFolder>()
.Where(i => i.IsVisible(user))
.SelectMany(i => i.PhysicalLocations)
.Select(i => i.Id)
.ToList();
return LinkedChildren
@@ -1228,9 +1234,16 @@ namespace MediaBrowser.Controller.Entities
return null;
}
}
else if (childLocationType == LocationType.FileSystem && !locations.Any(l => FileSystem.ContainsSubPath(l, child.Path)))
else if (childLocationType == LocationType.FileSystem)
{
return null;
var itemCollectionFolderIds =
LibraryManager.GetCollectionFolders(child, allUserRootChildren)
.Select(f => f.Id).ToList();
if (!itemCollectionFolderIds.Any(collectionFolderIds.Contains))
{
return null;
}
}
}
@@ -1323,7 +1336,7 @@ namespace MediaBrowser.Controller.Entities
}
else { newShortcutLinks = new List<LinkedChild>(); }
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer()))
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer(FileSystem)))
{
Logger.Info("Shortcut links have changed for {0}", Path);

View File

@@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities
return new[] {
new FileSystemMetadata
{
FullName = System.IO.Path.GetDirectoryName(Path),
FullName = FileSystem.GetDirectoryName(Path),
IsDirectory = true
}
};

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Entities
@@ -40,11 +41,18 @@ namespace MediaBrowser.Controller.Entities
public class LinkedChildComparer : IEqualityComparer<LinkedChild>
{
private readonly IFileSystem _fileSystem;
public LinkedChildComparer(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
public bool Equals(LinkedChild x, LinkedChild y)
{
if (x.Type == y.Type)
{
return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
return _fileSystem.AreEqual(x.Path, y.Path);
}
return false;
}

View File

@@ -125,7 +125,7 @@ namespace MediaBrowser.Controller.Entities.TV
return series.Path;
}
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
}

View File

@@ -311,7 +311,7 @@ namespace MediaBrowser.Controller.Entities
{
if (IsStacked)
{
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
if (!IsPlaceHolder)