[release-branch.go1.3] go.tools/godoc: fix index reading and writing

««« 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
This commit is contained in:
Andrew Gerrand 2014-06-13 16:54:49 +10:00
parent 52572e427b
commit 5b307dbe98
2 changed files with 3 additions and 1 deletions

View File

@ -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 {

View File

@ -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.