mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-04 04:23:02 +00:00
i dont like commits
This commit is contained in:
+7
-4
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -87,7 +88,7 @@ func init() {
|
||||
func runScrape(cmd *cobra.Command, args []string) error {
|
||||
cfg, err := loadAppConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("load app config for scrape command: %w", err)
|
||||
}
|
||||
|
||||
if scrapeSources != "" {
|
||||
@@ -122,7 +123,7 @@ func runScrape(cmd *cobra.Command, args []string) error {
|
||||
outputDir := resolveOutputDir(cfg, scrapeOutput)
|
||||
count, err := scrapeOne(cmd, cfg, source, outputDir)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("scrape source %q: %w", sourceURL, err)
|
||||
}
|
||||
|
||||
if cfg.Indexing.Enabled {
|
||||
@@ -151,7 +152,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
|
||||
Sources []appconfig.SourceConfig `yaml:"sources"`
|
||||
}
|
||||
if wrapErr := yaml.Unmarshal(raw, &wrapped); wrapErr != nil {
|
||||
return fmt.Errorf("parse sources file: %w", err)
|
||||
return fmt.Errorf("parse sources file: %w", wrapErr)
|
||||
}
|
||||
list = wrapped.Sources
|
||||
}
|
||||
@@ -167,6 +168,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
|
||||
success := 0
|
||||
failures := 0
|
||||
totalDocs := 0
|
||||
sourceErrors := make([]error, 0)
|
||||
for _, srcCfg := range list {
|
||||
source := sourceFromConfig(srcCfg)
|
||||
if source.Type == "" {
|
||||
@@ -189,6 +191,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
|
||||
if srcErr != nil {
|
||||
failures++
|
||||
fmt.Printf("✗ %s failed: %v\n", source.Name, srcErr)
|
||||
sourceErrors = append(sourceErrors, fmt.Errorf("%s: %w", source.Name, srcErr))
|
||||
continue
|
||||
}
|
||||
totalDocs += count
|
||||
@@ -204,7 +207,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
|
||||
|
||||
fmt.Printf("\nSummary: %d succeeded, %d failed, %d docs written\n", success, failures, totalDocs)
|
||||
if failures > 0 {
|
||||
return fmt.Errorf("one or more sources failed")
|
||||
return fmt.Errorf("one or more sources failed: %w", errors.Join(sourceErrors...))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user