From 5a5dc64a9686537757109f5357c509ed5ebdaa34 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 13 Jun 2014 16:49:32 +1000 Subject: [PATCH] go.tools/godoc: fix index reading and writing In command godoc, set IndexEnabled when the -write_index flag is set. Previously you would need to (unintuitively) set the -http flag to achieve this. In package godoc, set up the FS tree before loading the index, and then return before starting the index refresh loop. Previously the index would be loaded and then immediately refreshed, negating the benefits of the on-disk index. TBR=bradfitz R=golang-codereviews CC=golang-codereviews https://golang.org/cl/103370046 --- cmd/godoc/main.go | 1 + godoc/index.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/godoc/main.go b/cmd/godoc/main.go index 6c21e66b..46938734 100644 --- a/cmd/godoc/main.go +++ b/cmd/godoc/main.go @@ -221,6 +221,7 @@ func main() { corpus.IndexThrottle = *indexThrottle if *writeIndex { corpus.IndexThrottle = 1.0 + corpus.IndexEnabled = true } if *writeIndex || httpMode || *urlFlag != "" { if err := corpus.Init(); err != nil { diff --git a/godoc/index.go b/godoc/index.go index 944343c5..aeea29f9 100644 --- a/godoc/index.go +++ b/godoc/index.go @@ -1471,10 +1471,11 @@ func (c *Corpus) UpdateIndex() { func (c *Corpus) RunIndexer() { // initialize the index from disk if possible if c.IndexFiles != "" { + c.initFSTree() if err := c.readIndex(c.IndexFiles); err != nil { log.Printf("error reading index from file %s: %v", c.IndexFiles, err) - return } + return } // Repeatedly update the package directory tree and index.