all repos — searchix @ fc42a07294d26c42c1d91fc4dc89282033ae4e24

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: move http fetcher to struct variable

Alan Pearce
commit

fc42a07294d26c42c1d91fc4dc89282033ae4e24

parent

f0aab9c1174093efba3d796ce66f617473caf004

1 file changed, 6 insertions(+), 6 deletions(-)

changed files
M internal/fetcher/download.gointernal/fetcher/download.go
@@ -15,6 +15,7 @@
type DownloadFetcher struct { Source config.Source SourceFile string + fetcher *http.Fetcher *Options }
@@ -27,6 +28,10 @@ case config.Options, config.Packages:
return &DownloadFetcher{ Source: source, Options: options, + fetcher: http.NewFetcher(&http.Options{ + Logger: options.Logger.Named("http"), + Root: options.Root, + }), }, nil default: return nil, fault.Newf("unsupported importer type %s", source.Importer)
@@ -51,11 +56,6 @@ revisionFileName,
files[i.Source.Importer], } - fetcher := http.NewFetcher(&http.Options{ - Logger: i.Logger.Named("http"), - Root: i.Root, - }) - for _, basename := range filesToFetch { target := i.Source.JoinPath(basename) fetchURL, baseErr := url.JoinPath(i.Source.URL, basename)
@@ -70,7 +70,7 @@ ),
) } - body, err := fetcher.FetchFileIfNeeded(ctx, target, fetchURL) + body, err := i.fetcher.FetchFileIfNeeded(ctx, target, fetchURL) if err != nil { i.Logger.Warn("failed to fetch file", "url", fetchURL, "error", err)