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
This commit is contained in:
parent
93b08999a7
commit
5a5dc64a96
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue