From 6d3849d98da80e36101e11abd1d96fff075fd216 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 29 Apr 2013 11:22:33 -0400 Subject: [PATCH] image cleanup fixes --- .../ScheduledTasks/ImageCleanupTask.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs index ded2247fb8..d308cb74b0 100644 --- a/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs +++ b/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs @@ -138,6 +138,21 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks images = images.Concat(item.ScreenshotImagePaths); } + if (item.LocalTrailers != null) + { + images = item.LocalTrailers.Aggregate(images, (current, subItem) => current.Concat(GetPathsInUse(subItem))); + } + + if (item.ThemeSongs != null) + { + images = item.ThemeSongs.Aggregate(images, (current, subItem) => current.Concat(GetPathsInUse(subItem))); + } + + if (item.ThemeVideos != null) + { + images = item.ThemeVideos.Aggregate(images, (current, subItem) => current.Concat(GetPathsInUse(subItem))); + } + var video = item as Video; if (video != null && video.Chapters != null) @@ -145,22 +160,11 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks images = images.Concat(video.Chapters.Where(i => !string.IsNullOrEmpty(i.ImagePath)).Select(i => i.ImagePath)); } - if (item.LocalTrailers != null) - { - foreach (var subItem in item.LocalTrailers) - { - images = images.Concat(GetPathsInUse(subItem)); - } - } - var movie = item as Movie; if (movie != null && movie.SpecialFeatures != null) { - foreach (var subItem in movie.SpecialFeatures) - { - images = images.Concat(GetPathsInUse(subItem)); - } + images = movie.SpecialFeatures.Aggregate(images, (current, subItem) => current.Concat(GetPathsInUse(subItem))); } return images;