From 3737a8cf28c935016328dd034fa97e4ebe7f01ae Mon Sep 17 00:00:00 2001 From: "agrath@gmail.com" Date: Thu, 21 Jul 2011 13:15:20 -1200 Subject: [PATCH] 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 | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs index 5c2907a78c..fbb4c5d155 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/ExamineBackedMedia.cs @@ -7,6 +7,7 @@ using Examine; using UmbracoExamine; using Lucene.Net.Documents; using umbraco.interfaces; +using System.IO; namespace umbraco.MacroEngines @@ -17,17 +18,27 @@ namespace umbraco.MacroEngines public static ExamineBackedMedia GetUmbracoMedia(int id) { - //first check in Examine as this is WAY faster - var criteria = ExamineManager.Instance - .SearchProviderCollection["InternalSearcher"] - .CreateSearchCriteria("media"); - var filter = criteria.Id(id); - var results = ExamineManager - .Instance.SearchProviderCollection["InternalSearcher"] - .Search(filter.Compile()); - if (results.Any()) + try { - return new ExamineBackedMedia(results.First()); + //first check in Examine as this is WAY faster + var criteria = ExamineManager.Instance + .SearchProviderCollection["InternalSearcher"] + .CreateSearchCriteria("media"); + var filter = criteria.Id(id); + var results = ExamineManager + .Instance.SearchProviderCollection["InternalSearcher"] + .Search(filter.Compile()); + if (results.Any()) + { + return new ExamineBackedMedia(results.First()); + } + } + 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(id, true);