This commit is contained in:
parent
5bc2f53ef1
commit
c33a997dc5
3 changed files with 20 additions and 6 deletions
15
config.go
15
config.go
|
@ -386,26 +386,25 @@ func loadConfig() Config {
|
|||
crawlerProxyRetry := getConfigValue(cfg.Section("Proxies").Key("CrawlerProxyRetry"), defaultConfig.CrawlerProxyRetry, strconv.Atoi)
|
||||
|
||||
// MetaSearch
|
||||
searchXInstances := strings.Split(getConfigValueString(cfg.Section("MetaSearches").Key("LibreXInstances"), strings.Join(defaultConfig.LibreXInstances, ",")), ",")
|
||||
searchXInstances := strings.Split(getConfigValueString(cfg.Section("MetaSearch").Key("LibreXInstances"), strings.Join(defaultConfig.LibreXInstances, ",")), ",")
|
||||
textList := strings.Split(getConfigValueString(cfg.Section("MetaSearch").Key("Text"), strings.Join(defaultConfig.MetaSearch.Text, ",")), ",")
|
||||
imageList := strings.Split(getConfigValueString(cfg.Section("MetaSearch").Key("Image"), strings.Join(defaultConfig.MetaSearch.Image, ",")), ",")
|
||||
filesList := strings.Split(getConfigValueString(cfg.Section("MetaSearch").Key("Files"), strings.Join(defaultConfig.MetaSearch.Files, ",")), ",")
|
||||
videoList := strings.Split(getConfigValueString(cfg.Section("MetaSearch").Key("Video"), strings.Join(defaultConfig.MetaSearch.Video, ",")), ",")
|
||||
|
||||
// Load default values for MetaSearch if they are empty
|
||||
if len(textList) == 1 && textList[0] == "" {
|
||||
if isEmptyList(textList) {
|
||||
textList = defaultConfig.MetaSearch.Text
|
||||
}
|
||||
if len(imageList) == 1 && imageList[0] == "" {
|
||||
if isEmptyList(imageList) {
|
||||
imageList = defaultConfig.MetaSearch.Image
|
||||
}
|
||||
if len(filesList) == 1 && filesList[0] == "" {
|
||||
if isEmptyList(filesList) {
|
||||
filesList = defaultConfig.MetaSearch.Files
|
||||
}
|
||||
if len(videoList) == 1 && videoList[0] == "" {
|
||||
if isEmptyList(videoList) {
|
||||
videoList = defaultConfig.MetaSearch.Video
|
||||
}
|
||||
|
||||
// Indexing
|
||||
concurrentStandardCrawlers := getConfigValue(cfg.Section("Indexer").Key("ConcurrentStandardCrawlers"), defaultConfig.ConcurrentStandardCrawlers, strconv.Atoi)
|
||||
concurrentChromeCrawlers := getConfigValue(cfg.Section("Indexer").Key("ConcurrentChromeCrawlers"), defaultConfig.ConcurrentChromeCrawlers, strconv.Atoi)
|
||||
|
@ -470,6 +469,10 @@ func loadConfig() Config {
|
|||
}
|
||||
}
|
||||
|
||||
func isEmptyList(list []string) bool {
|
||||
return len(list) == 0 || (len(list) == 1 && strings.TrimSpace(list[0]) == "")
|
||||
}
|
||||
|
||||
func setIfChanged(sec *ini.Section, key string, value string, defaultValue string) {
|
||||
if value != defaultValue {
|
||||
sec.Key(key).SetValue(value)
|
||||
|
|
|
@ -138,5 +138,10 @@ func main() {
|
|||
printInfo("Indexer is disabled.")
|
||||
}
|
||||
|
||||
// if len(config.MetaSearch.Text) == 0 {
|
||||
// log.Fatal("No text search engines are enabled in config (MetaSearch.Text)")
|
||||
// }
|
||||
// fmt.Printf("Loaded config.MetaSearch.Text: %#v\n", config.MetaSearch.Text)
|
||||
|
||||
runServer()
|
||||
}
|
||||
|
|
6
init.go
6
init.go
|
@ -12,6 +12,7 @@ import (
|
|||
var config Config
|
||||
|
||||
func main() {
|
||||
|
||||
// Command-line flags
|
||||
portFlag := flag.Int("port", 0, "Port number to run the application (overrides config)")
|
||||
domainFlag := flag.String("domain", "", "Domain address for the application (overrides config)")
|
||||
|
@ -109,5 +110,10 @@ func main() {
|
|||
printInfo("RAM cache is disabled.")
|
||||
}
|
||||
|
||||
// if len(config.MetaSearch.Text) == 0 {
|
||||
// log.Fatal("No text search engines are enabled in config (MetaSearch.Text)")
|
||||
// }
|
||||
// fmt.Printf("Loaded config.MetaSearch.Text: %#v\n", config.MetaSearch.Text)
|
||||
|
||||
runServer()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue