diff --git a/config.go b/config.go index 032db94..492cbd8 100644 --- a/config.go +++ b/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) diff --git a/init-extra.go b/init-extra.go index e37649a..6810f7c 100644 --- a/init-extra.go +++ b/init-extra.go @@ -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() } diff --git a/init.go b/init.go index b94c566..5b8f934 100644 --- a/init.go +++ b/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() }