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:
lakshit verma 2026-08-21 21:44:48 +05:30
parent c8207996d1
commit d407ac0840
No known key found for this signature in database

View file

@ -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
}