From cb26cb94579b772fa7825c6769dc7ace38217168 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 10 Oct 2016 14:18:28 -0400 Subject: update program queries --- .../Collections/CollectionManager.cs | 40 +++------------------- 1 file changed, 5 insertions(+), 35 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Collections/CollectionManager.cs') diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 1b6c44c5e..cb2bd645d 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -219,7 +219,9 @@ namespace MediaBrowser.Server.Implementations.Collections foreach (var itemId in itemIds) { - var child = collection.LinkedChildren.FirstOrDefault(i => i.ItemId.HasValue && i.ItemId.Value == itemId); + var childItem = _libraryManager.GetItemById(itemId); + + var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == itemId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); if (child == null) { @@ -228,47 +230,15 @@ namespace MediaBrowser.Server.Implementations.Collections list.Add(child); - var childItem = _libraryManager.GetItemById(itemId); - if (childItem != null) { itemList.Add(childItem); } } - var shortcutFiles = _fileSystem - .GetFilePaths(collection.Path) - .Where(i => _fileSystem.IsShortcut(i)) - .ToList(); - - var shortcutFilesToDelete = list.Where(child => !string.IsNullOrWhiteSpace(child.Path) && child.Type == LinkedChildType.Shortcut) - .Select(child => shortcutFiles.FirstOrDefault(i => string.Equals(child.Path, _fileSystem.ResolveShortcut(i), StringComparison.OrdinalIgnoreCase))) - .Where(i => !string.IsNullOrWhiteSpace(i)) - .ToList(); - - foreach (var file in shortcutFilesToDelete) - { - _iLibraryMonitor.ReportFileSystemChangeBeginning(file); - } - - try - { - foreach (var file in shortcutFilesToDelete) - { - _fileSystem.DeleteFile(file); - } - - foreach (var child in list) - { - collection.LinkedChildren.Remove(child); - } - } - finally + foreach (var child in list) { - foreach (var file in shortcutFilesToDelete) - { - _iLibraryMonitor.ReportFileSystemChangeComplete(file, false); - } + collection.LinkedChildren.Remove(child); } collection.UpdateRatingToContent(); -- cgit v1.2.3