/* Function: Start */ public bool Start(ErrorList errorList) { StartupIssues newStartupIssues = StartupIssues.None; // Load SearchIndex.nd bool hasBinaryFile; if (!EngineInstance.HasIssues(StartupIssues.NeedToStartFresh | StartupIssues.CommentIDsInvalidated | StartupIssues.CodeIDsInvalidated | StartupIssues.CommentIDsInvalidated)) { SearchIndex_nd binaryFileParser = new SearchIndex_nd(); hasBinaryFile = binaryFileParser.Load(Target.WorkingDataFolder + "/SearchIndex.nd", out prefixTopicIDs); } else { prefixTopicIDs = new StringTable <NumberSet>(KeySettingsForPrefixes); hasBinaryFile = false; } if (!hasBinaryFile) { // If we don't have the binary file we need to reparse all the source files to rebuild the index. However, setting NeedToReparseAllFiles // isn't enough because it will reparse those files, send them to CodeDB, and then CodeDB won't send topic updates if the underlying // content hasn't changed. So f**k it, blow it all up and start over. newStartupIssues |= StartupIssues.NeedToStartFresh; } // Add watchers EngineInstance.CodeDB.AddChangeWatcher(this); EngineInstance.AddStartupWatcher(this); if (newStartupIssues != StartupIssues.None) { EngineInstance.AddStartupIssues(newStartupIssues, dontNotify: this); } started = true; return(true); }
/* Function: Dispose */ protected override void Dispose(bool strictRulesApply) { if (!strictRulesApply) { try { SearchIndex_nd binaryFileParser = new SearchIndex_nd(); binaryFileParser.Save(Target.WorkingDataFolder + "/SearchIndex.nd", prefixTopicIDs); // Prior to Natural Docs 2.1 SearchIndex.nd was saved in the main working data folder instead of the output target's. // Clean it up if it still exists there. if (System.IO.File.Exists(EngineInstance.Config.WorkingDataFolder + "/SearchIndex.nd")) { System.IO.File.Delete(EngineInstance.Config.WorkingDataFolder + "/SearchIndex.nd"); } } catch { } } }