mirror of
https://github.com/vee1e/subidx.git
synced 2026-09-01 09:50:18 +00:00
loglist: error when every log list source fails
FetchAll swallowed per-source errors and always returned nil, so all three upstreams failing was indistinguishable from an empty log list and the hourly sync silently tailed nothing. Total failure now returns an error; partial failure logs a warning.
This commit is contained in:
parent
c8207996d1
commit
d407ac0840
1 changed files with 9 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -89,11 +90,13 @@ func FetchAll(client *http.Client) ([]Log, error) {
|
|||
urls := []string{ChromeList, ChromeAllList, AppleList}
|
||||
seen := make(map[string]*Log)
|
||||
var order []string
|
||||
var fetched int
|
||||
for _, u := range urls {
|
||||
list, err := fetchOne(client, u)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
fetched++
|
||||
for i := range list.Operators {
|
||||
for j := range list.Operators[i].Logs {
|
||||
lg := &list.Operators[i].Logs[j]
|
||||
|
|
@ -121,6 +124,12 @@ func FetchAll(client *http.Client) ([]Log, error) {
|
|||
for _, id := range order {
|
||||
out = append(out, *seen[id])
|
||||
}
|
||||
if fetched == 0 {
|
||||
return nil, fmt.Errorf("all %d log list sources failed", len(urls))
|
||||
}
|
||||
if fetched < len(urls) {
|
||||
log.Printf("loglist: %d of %d sources failed", len(urls)-fetched, len(urls))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue