From 914875b9966435427e943bd2f553a4b63d086851 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Laval?= Date: Mon, 17 Dec 2012 19:54:21 +0100 Subject: [PATCH] [monkeydoc] Protect GetIndex and GetSearchIndex and make them returns null if somethings goes wrong. --- mcs/tools/monkeydoc/Monkeydoc/RootTree.cs | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mcs/tools/monkeydoc/Monkeydoc/RootTree.cs b/mcs/tools/monkeydoc/Monkeydoc/RootTree.cs index b2913fd19e0..799ed9514f6 100644 --- a/mcs/tools/monkeydoc/Monkeydoc/RootTree.cs +++ b/mcs/tools/monkeydoc/Monkeydoc/RootTree.cs @@ -404,12 +404,16 @@ namespace MonkeyDoc public IndexReader GetIndex () { - string text = Path.Combine (this.basedir, "monodoc.index"); - if (File.Exists (text)) - return IndexReader.Load (text); + try { + string text = Path.Combine (this.basedir, "monodoc.index"); + if (File.Exists (text)) + return IndexReader.Load (text); - text = Path.Combine (Settings.Get ("monodocIndexDirectory"), "monodoc.index"); - return IndexReader.Load (text); + text = Path.Combine (Settings.Get ("monodocIndexDirectory"), "monodoc.index"); + return IndexReader.Load (text); + } catch { + return null; + } } public static void MakeIndex () @@ -443,12 +447,15 @@ namespace MonkeyDoc public SearchableIndex GetSearchIndex () { - string text = Path.Combine (this.basedir, "search_index"); - if (System.IO.Directory.Exists (text)) { + try { + string text = Path.Combine (this.basedir, "search_index"); + if (System.IO.Directory.Exists (text)) + return SearchableIndex.Load (text); + text = Path.Combine (Settings.Get ("docPath"), "search_index"); return SearchableIndex.Load (text); + } catch { + return null; } - text = Path.Combine (Settings.Get ("docDir"), "search_index"); - return SearchableIndex.Load (text); } public static void MakeSearchIndex () -- 2.25.1