aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-07-12 15:56:40 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-07-12 15:56:40 -0400
commitdab5003d6bba57c27f4111653b36d39862b5b6fd (patch)
treebdf7462c3718eb729f71b1245c3f651b016e8412 /MediaBrowser.Server.Implementations/Library/LibraryManager.cs
parent3370fb072e71ad93c540d50d859d6cbe85552735 (diff)
added collection type
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs59
1 files changed, 57 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 810f54c26..c9fb95c86 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -487,7 +487,7 @@ namespace MediaBrowser.Server.Implementations.Library
// When resolving the root, we need it's grandchildren (children of user views)
var flattenFolderDepth = isPhysicalRoot ? 2 : 0;
- args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, _logger, flattenFolderDepth: flattenFolderDepth, args: args, resolveShortcuts: isPhysicalRoot || args.IsVf);
+ args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf);
// Need to remove subpaths that may have been resolved from shortcuts
// Example: if \\server\movies exists, then strip out \\server\movies\action
@@ -1168,10 +1168,23 @@ namespace MediaBrowser.Server.Implementations.Library
.Select(dir => new VirtualFolderInfo
{
Name = Path.GetFileName(dir),
- Locations = Directory.EnumerateFiles(dir, "*.lnk", SearchOption.TopDirectoryOnly).Select(FileSystem.ResolveShortcut).OrderBy(i => i).ToList()
+
+ Locations = Directory.EnumerateFiles(dir, "*.lnk", SearchOption.TopDirectoryOnly)
+ .Select(FileSystem.ResolveShortcut)
+ .OrderBy(i => i)
+ .ToList(),
+
+ CollectionType = GetCollectionType(dir)
});
}
+ private string GetCollectionType(string path)
+ {
+ return new DirectoryInfo(path).EnumerateFiles("*.collection", SearchOption.TopDirectoryOnly)
+ .Select(i => Path.GetFileNameWithoutExtension(i.FullName))
+ .FirstOrDefault();
+ }
+
/// <summary>
/// Gets the item by id.
/// </summary>
@@ -1405,5 +1418,47 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
}
+
+ /// <summary>
+ /// Finds the type of the collection.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <returns>System.String.</returns>
+ public string FindCollectionType(BaseItem item)
+ {
+ while (!(item.Parent is AggregateFolder) && item.Parent != null)
+ {
+ item = item.Parent;
+ }
+
+ if (item == null)
+ {
+ return null;
+ }
+
+ var collectionTypes = _userManager.Users
+ .Select(i => i.RootFolder)
+ .Distinct()
+ .SelectMany(i => i.Children)
+ .OfType<CollectionFolder>()
+ .Where(i =>
+ {
+ try
+ {
+ return i.LocationType != LocationType.Remote && i.LocationType != LocationType.Virtual &&
+ i.ResolveArgs.PhysicalLocations.Contains(item.Path);
+ }
+ catch (IOException ex)
+ {
+ _logger.ErrorException("Error getting resolve args for {0}", ex, i.Path);
+ return false;
+ }
+ })
+ .Select(i => i.CollectionType)
+ .Where(i => !string.IsNullOrEmpty(i))
+ .Distinct();
+
+ return collectionTypes.SingleOrDefault();
+ }
}
}