Update Emby.Server.Implementations/ScheduledTasks/Tasks/CleanupCollectionAndPlaylistPathsTask.cs

Co-authored-by: Bond-009 <bond.009@outlook.com>
pull/10234/head
Tim Eisele 9 months ago committed by GitHub
parent 783bb8a8cb
commit fccea4625d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -112,17 +112,17 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
private void CleanupLinkedChildren<T>(T folder, CancellationToken cancellationToken)
where T : Folder
{
var itemsToRemove = new List<LinkedChild>();
List<LinkedChild> itemsToRemove = null;
foreach (var linkedChild in folder.LinkedChildren)
{
if (!File.Exists(folder.Path))
{
_logger.LogInformation("Item in {FolderName} cannot be found at {ItemPath}", folder.Name, linkedChild.Path);
itemsToRemove.Add(linkedChild);
(itemsToRemove ??= new List<LinkedChild>()).Add(linkedChild);
}
}
if (itemsToRemove.Count != 0)
if (itemsToRemove is not null)
{
_logger.LogDebug("Updating {FolderName}", folder.Name);
folder.LinkedChildren = folder.LinkedChildren.Except(itemsToRemove).ToArray();

Loading…
Cancel
Save