diff --git a/updater/updating.go b/updater/updating.go index 1283313..246143b 100644 --- a/updater/updating.go +++ b/updater/updating.go @@ -15,20 +15,26 @@ import ( "github.com/safing/portbase/log" ) -// UpdateIndexes downloads all indexes and returns the first error encountered. +// UpdateIndexes downloads all indexes. An error is only returned when all +// indexes fail to update. func (reg *ResourceRegistry) UpdateIndexes(ctx context.Context) error { - var firstErr error + var lastErr error + var anySuccess bool client := &http.Client{} for _, idx := range reg.getIndexes() { if err := reg.downloadIndex(ctx, client, idx); err != nil { - if firstErr == nil { - firstErr = err - } + lastErr = err + log.Warningf("%s: failed to update index %s: %s", reg.Name, idx.Path, err) + } else { + anySuccess = true } } - return firstErr + if !anySuccess { + return fmt.Errorf("failed to update all indexes, last error was: %s", lastErr) + } + return nil } func (reg *ResourceRegistry) downloadIndex(ctx context.Context, client *http.Client, idx Index) error {