From 3a7609cba00a1fd2364a9caf4e03324c56ea5d41 Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 28 Jul 2011 09:44:23 -1200 Subject: [PATCH] Another fix for Catch FileNotFound exceptions in ExamineBackedMedia which are thrown by Examine currently (bug?) on a LoadBalanced file store after a publish occurs. When caught, ExamineBackedMedia will fall back to GetMedia as if the media item wasn't in the examine index --- .../RazorDynamicNode/ExamineBackedMedia.cs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs index fbb4c5d155..462dd59474 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs @@ -302,17 +302,26 @@ namespace umbraco.MacroEngines } private static List GetChildrenMedia(int ParentId) { - //first check in Examine as this is WAY faster - var criteria = ExamineManager.Instance - .SearchProviderCollection["InternalSearcher"] - .CreateSearchCriteria("media"); - var filter = criteria.ParentId(ParentId); - var results = ExamineManager - .Instance.SearchProviderCollection["InternalSearcher"] - .Search(filter.Compile()); - if (results.Any()) + try { - return results.ToList().ConvertAll(result => new ExamineBackedMedia(result)); + //first check in Examine as this is WAY faster + var criteria = ExamineManager.Instance + .SearchProviderCollection["InternalSearcher"] + .CreateSearchCriteria("media"); + var filter = criteria.ParentId(ParentId); + var results = ExamineManager + .Instance.SearchProviderCollection["InternalSearcher"] + .Search(filter.Compile()); + if (results.Any()) + { + return results.ToList().ConvertAll(result => new ExamineBackedMedia(result)); + } + } + catch (FileNotFoundException) + { + //Currently examine is throwing FileNotFound exceptions when we have a loadbalanced filestore and a node is published in umbraco + //See this thread: http://examine.cdodeplex.com/discussions/264341 + //Catch the exception here for the time being, and just fallback to GetMedia } var media = umbraco.library.GetMedia(ParentId, true);