From 740a10a4e3f85ffcfd26ec18263d4c78d4b14ecc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 10 Sep 2013 14:56:00 -0400 Subject: de-normalize item by name data. create counts during library scan for fast access. --- MediaBrowser.Controller/Entities/BaseItem.cs | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index fb22607692..4887af2cf3 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1537,5 +1537,58 @@ namespace MediaBrowser.Controller.Entities // Refresh metadata return RefreshMetadata(CancellationToken.None, forceSave: true); } + + /// + /// Validates that images within the item are still on the file system + /// + public void ValidateImages() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedKeys = Images + .ToList() + .Where(image => !File.Exists(image.Value)) + .Select(i => i.Key) + .ToList(); + + // Now remove them from the dictionary + foreach (var key in deletedKeys) + { + Images.Remove(key); + } + } + + /// + /// Validates that backdrops within the item are still on the file system + /// + public void ValidateBackdrops() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedImages = BackdropImagePaths + .Where(path => !File.Exists(path)) + .ToList(); + + // Now remove them from the dictionary + foreach (var path in deletedImages) + { + BackdropImagePaths.Remove(path); + } + } + + /// + /// Validates the screenshots. + /// + public void ValidateScreenshots() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedImages = ScreenshotImagePaths + .Where(path => !File.Exists(path)) + .ToList(); + + // Now remove them from the dictionary + foreach (var path in deletedImages) + { + ScreenshotImagePaths.Remove(path); + } + } } } -- cgit v1.2.3