[monkeydoc] Protect GetIndex and GetSearchIndex and make them returns null if somethi...
authorJérémie Laval <jeremie.laval@gmail.com>
Mon, 17 Dec 2012 18:54:21 +0000 (19:54 +0100)
committerJérémie Laval <jeremie.laval@gmail.com>
Tue, 18 Dec 2012 09:43:55 +0000 (10:43 +0100)
mcs/tools/monkeydoc/Monkeydoc/RootTree.cs

index b2913fd19e00b32e66a0a1e0000b6d767850acb2..799ed9514f6a47d0d734ca69b9d79e264c53ec4b 100644 (file)
@@ -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 ()