From 588fb9e82bbf58fae5d8d5643c57abfc49639e83 Mon Sep 17 00:00:00 2001 From: gnattu Date: Sat, 11 May 2024 03:54:41 +0800 Subject: [PATCH 1/2] Don't assume library change only on item count The library will also be updated when the number of children remains the same before and after scanning. For example, if one video file is removed and replaced with another version, we still need to remove the old one in this case. Signed-off-by: gnattu --- MediaBrowser.Controller/Entities/Folder.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index f39fa79eb4..f49e5f7690 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -421,13 +421,12 @@ namespace MediaBrowser.Controller.Entities validChildren.Add(child); } + // That's all the new and changed ones - now see if there are any that are missing + var itemsRemoved = currentChildren.Values.Except(validChildren).ToList(); var shouldRemove = !IsRoot || allowRemoveRoot; // If it's an AggregateFolder, don't remove - if (shouldRemove && currentChildren.Count != validChildren.Count) + if (shouldRemove && itemsRemoved.Count > 0) { - // That's all the new and changed ones - now see if there are any that are missing - var itemsRemoved = currentChildren.Values.Except(validChildren).ToList(); - foreach (var item in itemsRemoved) { if (item.IsFileProtocol) From 47b79df1360154fa3396904f1eb62f7f73be7a01 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 11 May 2024 10:56:14 -0400 Subject: [PATCH 2/2] Update MediaBrowser.Controller/Entities/Folder.cs --- MediaBrowser.Controller/Entities/Folder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index f49e5f7690..236e47f959 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -421,7 +421,7 @@ namespace MediaBrowser.Controller.Entities validChildren.Add(child); } - // That's all the new and changed ones - now see if there are any that are missing + // That's all the new and changed ones - now see if any have been removed and need cleanup var itemsRemoved = currentChildren.Values.Except(validChildren).ToList(); var shouldRemove = !IsRoot || allowRemoveRoot; // If it's an AggregateFolder, don't remove