aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/Folder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/Folder.cs')
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs66
1 files changed, 50 insertions, 16 deletions
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 627f657ab..7dfe7f22e 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -264,7 +264,7 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember]
public IEnumerable<BaseItem> Children
{
- get { return ActualChildren; }
+ get { return ActualChildren.Where(i => !i.IsHidden); }
}
/// <summary>
@@ -905,13 +905,6 @@ namespace MediaBrowser.Controller.Entities
/// <returns>BaseItem.</returns>
private BaseItem GetLinkedChild(LinkedChild info)
{
- if (string.IsNullOrEmpty(info.Path))
- {
- throw new ArgumentException("Encountered linked child with empty path.");
- }
-
- BaseItem item = null;
-
// First get using the cached Id
if (info.ItemId.HasValue)
{
@@ -920,20 +913,19 @@ namespace MediaBrowser.Controller.Entities
return null;
}
- item = LibraryManager.GetItemById(info.ItemId.Value);
- }
+ var itemById = LibraryManager.GetItemById(info.ItemId.Value);
- // If still null, search by path
- if (item == null)
- {
- item = LibraryManager.RootFolder.FindByPath(info.Path);
+ if (itemById != null)
+ {
+ return itemById;
+ }
}
+ var item = FindLinkedChild(info);
+
// If still null, log
if (item == null)
{
- Logger.Warn("Unable to find linked item at {0}", info.Path);
-
// Don't keep searching over and over
info.ItemId = Guid.Empty;
}
@@ -946,6 +938,43 @@ namespace MediaBrowser.Controller.Entities
return item;
}
+ private BaseItem FindLinkedChild(LinkedChild info)
+ {
+ if (!string.IsNullOrEmpty(info.Path))
+ {
+ var itemByPath = LibraryManager.RootFolder.FindByPath(info.Path);
+
+ if (itemByPath == null)
+ {
+ Logger.Warn("Unable to find linked item at path {0}", info.Path);
+ }
+
+ return itemByPath;
+ }
+
+ if (!string.IsNullOrWhiteSpace(info.ItemName) && !string.IsNullOrWhiteSpace(info.ItemType))
+ {
+ return LibraryManager.RootFolder.RecursiveChildren.FirstOrDefault(i =>
+ {
+ if (string.Equals(i.Name, info.ItemName, StringComparison.OrdinalIgnoreCase))
+ {
+ if (string.Equals(i.GetType().Name, info.ItemType, StringComparison.OrdinalIgnoreCase))
+ {
+ if (info.ItemYear.HasValue)
+ {
+ return info.ItemYear.Value == (i.ProductionYear ?? -1);
+ }
+ return true;
+ }
+ }
+
+ return false;
+ });
+ }
+
+ return null;
+ }
+
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
{
var changesFound = false;
@@ -1106,5 +1135,10 @@ namespace MediaBrowser.Controller.Entities
return GetRecursiveChildren(user).Where(i => !i.IsFolder && i.LocationType != LocationType.Virtual)
.All(i => i.IsUnplayed(user));
}
+
+ public IEnumerable<BaseItem> GetHiddenChildren()
+ {
+ return ActualChildren.Where(i => i.IsHidden);
+ }
}
}