mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
feat: log multifetcher errors
This is to make it easier to understand why the multifetcher is
falling back to a different fetcher.
(cherry picked from commit 4f3eb4cdd4)
This commit is contained in:
parent
db85387c67
commit
418bc6e709
@ -2,6 +2,7 @@ package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@ -39,7 +40,8 @@ type limitReadCloser struct {
|
||||
|
||||
// NewMultiFetcher creates a MultiFetcher with the given Fetchers. The
|
||||
// Fetchers are tried in order ther passed to this function.
|
||||
func NewMultiFetcher(f ...Fetcher) Fetcher {
|
||||
func NewMultiFetcher(f ...Fetcher) *MultiFetcher {
|
||||
|
||||
mf := &MultiFetcher{
|
||||
fetchers: make([]Fetcher, len(f)),
|
||||
}
|
||||
@ -56,6 +58,7 @@ func (f *MultiFetcher) Fetch(ctx context.Context, ipfsPath string) (io.ReadClose
|
||||
if err == nil {
|
||||
return rc, nil
|
||||
}
|
||||
fmt.Printf("Error fetching: %s\n", err.Error())
|
||||
errs = multierror.Append(errs, err)
|
||||
}
|
||||
return nil, errs
|
||||
|
||||
Loading…
Reference in New Issue
Block a user