From 5b307dbe98cfd0b6dfd40eacf9fb0c9bcb28b0a6 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 13 Jun 2014 16:54:49 +1000 Subject: [PATCH] [release-branch.go1.3] go.tools/godoc: fix index reading and writing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ««« CL 103370046 / 3b66a5dfbfe1 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 »»» TBR=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/105190043 --- 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 eb5182de..efccd64c 100644 --- a/godoc/index.go +++ b/godoc/index.go @@ -1477,10 +1477,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.