diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/Folder.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 943c9d882..cdd503bba 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -86,6 +86,15 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + + [IgnoreDataMember] public virtual bool SupportsCumulativeRunTimeTicks { get @@ -360,6 +369,11 @@ namespace MediaBrowser.Controller.Entities var validChildren = new List<BaseItem>(); + var allLibraryPaths = LibraryManager + .GetVirtualFolders() + .SelectMany(i => i.Locations) + .ToList(); + if (locationType != LocationType.Remote && locationType != LocationType.Virtual) { IEnumerable<BaseItem> nonCachedChildren; @@ -393,7 +407,6 @@ namespace MediaBrowser.Controller.Entities if (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child)) { - await currentChild.UpdateIsOffline(false).ConfigureAwait(false); validChildren.Add(currentChild); continue; @@ -420,9 +433,8 @@ namespace MediaBrowser.Controller.Entities { } - else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path)) + else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path, allLibraryPaths)) { - await item.UpdateIsOffline(true).ConfigureAwait(false); } else { @@ -437,7 +449,6 @@ namespace MediaBrowser.Controller.Entities Logger.Debug("Removed item: " + item.Path); item.SetParent(null); - item.IsOffline = false; await LibraryManager.DeleteItem(item, new DeleteOptions { DeleteFileLocation = false }).ConfigureAwait(false); LibraryManager.ReportItemRemoved(item); } @@ -603,6 +614,11 @@ namespace MediaBrowser.Controller.Entities /// <returns><c>true</c> if the specified path is offline; otherwise, <c>false</c>.</returns> public static bool IsPathOffline(string path) { + return IsPathOffline(path, LibraryManager.GetVirtualFolders().SelectMany(i => i.Locations).ToList()); + } + + public static bool IsPathOffline(string path, List<string> allLibraryPaths) + { if (FileSystem.FileExists(path)) { return false; @@ -618,31 +634,20 @@ namespace MediaBrowser.Controller.Entities return false; } - path = System.IO.Path.GetDirectoryName(path); - } + if (allLibraryPaths.Contains(path, StringComparer.OrdinalIgnoreCase)) + { + return true; + } - if (ContainsPath(LibraryManager.GetVirtualFolders(), originalPath)) - { - return true; + path = System.IO.Path.GetDirectoryName(path); } - return false; - } - - /// <summary> - /// Determines whether the specified folders contains path. - /// </summary> - /// <param name="folders">The folders.</param> - /// <param name="path">The path.</param> - /// <returns><c>true</c> if the specified folders contains path; otherwise, <c>false</c>.</returns> - private static bool ContainsPath(IEnumerable<VirtualFolderInfo> folders, string path) - { - return folders.SelectMany(i => i.Locations).Any(i => ContainsPath(i, path)); + return allLibraryPaths.Any(i => ContainsPath(i, originalPath)); } private static bool ContainsPath(string parent, string path) { - return string.Equals(parent, path, StringComparison.OrdinalIgnoreCase) || FileSystem.ContainsSubPath(parent, path); + return FileSystem.AreEqual(parent, path) || FileSystem.ContainsSubPath(parent, path); } /// <summary> @@ -1327,7 +1332,7 @@ namespace MediaBrowser.Controller.Entities if (!user.Configuration.DisplayMissingEpisodes || !user.Configuration.DisplayUnairedEpisodes) { - query.ExcludeLocationTypes = new[] { LocationType.Virtual }; + query.IsVirtualItem = false; } var itemsResult = await GetItems(query).ConfigureAwait(false); @@ -1366,7 +1371,7 @@ namespace MediaBrowser.Controller.Entities { Recursive = true, IsFolder = false, - ExcludeLocationTypes = new[] { LocationType.Virtual }, + IsVirtualItem = false, EnableTotalRecordCount = false }).Result; |
