Follow-up to c924281, which introduced two defects of its own. 1. indexing.Config was a private config island: index paths existed nowhere in internal/config or config.example.toml, so they were undiscoverable and unsettable by anyone reading the real configuration. Now [indexing] in config.toml, defined in its own internal/config/ indexer.go rather than appended to the 21-struct config.go, and its defaulting lives with it as IndexingConfig.withDefaults so finalize delegates instead of growing. Paths default off work_dir, keeping the two archied instances on one host from sharing an index. Documented in config.example.toml. internal/indexing keeps its own plain Config and does NOT import internal/config, so it stays a straight diff against its tau original. 2. A failed index build was invisible. refreshAsync wrote the reason to a database column with no reader and degraded to unindexed search in silence — the failure mode that costs hours precisely because nothing appears to be wrong. Every give-up path now logs, and a successful build logs once. The logger is resolved at the point of use, not in the constructor: a Manager can be built as a struct literal (the ported tests do), and constructor-only defaulting panicked on the build goroutine, where a panic takes the daemon with it. Regression test covers the zero and nil Manager.
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package config
|
|
|
|
import "path/filepath"
|
|
|
|
// IndexingConfig locates the workspace codesearch index.
|
|
//
|
|
// The index is a large, fully rebuildable artifact, so both paths are
|
|
// settable to allow putting it on different storage from the task work tree.
|
|
type IndexingConfig struct {
|
|
// IndexDir holds the codesearch sidecar files.
|
|
IndexDir string `toml:"index_dir" yaml:"index_dir" json:"index_dir,omitempty"`
|
|
// DBPath is the SQLite database holding index lifecycle metadata.
|
|
DBPath string `toml:"db_path" yaml:"db_path" json:"db_path,omitempty"`
|
|
}
|
|
|
|
// withDefaults fills unset paths from the daemon's work directory.
|
|
//
|
|
// Deriving from workDir rather than a shared data home is deliberate: two
|
|
// archied instances run on one host, each with its own work_dir, so this
|
|
// keeps their indexes separate without either having to configure anything.
|
|
func (c IndexingConfig) withDefaults(workDir string) IndexingConfig {
|
|
if c.IndexDir == "" {
|
|
c.IndexDir = filepath.Join(workDir, "indexes")
|
|
}
|
|
if c.DBPath == "" {
|
|
c.DBPath = filepath.Join(workDir, "workspace-indexes.db")
|
|
}
|
|
return c
|
|
}
|