pass url to Download(), not constructor

This commit is contained in:
marco 2024-04-22 12:43:27 +02:00
parent aebf85613e
commit c07835fab3
3 changed files with 6 additions and 6 deletions

View file

@ -42,7 +42,7 @@ func downloadDataSet(dataFolder string, force bool, reader io.Reader, logger *lo
} }
d := downloader. d := downloader.
New(dataS.SourceURL). New().
WithHTTPClient(hubClient). WithHTTPClient(hubClient).
ToFile(destPath). ToFile(destPath).
CompareContent(). CompareContent().
@ -55,7 +55,7 @@ func downloadDataSet(dataFolder string, force bool, reader io.Reader, logger *lo
ctx := context.TODO() ctx := context.TODO()
downloaded, err := d.Download(ctx) downloaded, err := d.Download(ctx, dataS.SourceURL)
if err != nil { if err != nil {
return fmt.Errorf("while getting data: %w", err) return fmt.Errorf("while getting data: %w", err)
} }

View file

@ -121,7 +121,7 @@ func (i *Item) FetchContentTo(destPath string) (bool, string, error) {
} }
d := downloader. d := downloader.
New(url). New().
WithHTTPClient(hubClient). WithHTTPClient(hubClient).
ToFile(destPath). ToFile(destPath).
WithMakeDirs(true). WithMakeDirs(true).
@ -133,7 +133,7 @@ func (i *Item) FetchContentTo(destPath string) (bool, string, error) {
ctx := context.TODO() ctx := context.TODO()
downloaded, err := d.Download(ctx) downloaded, err := d.Download(ctx, url)
if err != nil { if err != nil {
return false, "", fmt.Errorf("while downloading %s to %s: %w", i.Name, url, err) return false, "", fmt.Errorf("while downloading %s to %s: %w", i.Name, url, err)
} }

View file

@ -44,12 +44,12 @@ func (r *RemoteHubCfg) fetchIndex(destPath string) (bool, error) {
ctx := context.TODO() ctx := context.TODO()
downloaded, err := downloader. downloaded, err := downloader.
New(url). New().
WithHTTPClient(hubClient). WithHTTPClient(hubClient).
ToFile(destPath). ToFile(destPath).
CompareContent(). CompareContent().
WithLogger(logrus.WithFields(logrus.Fields{"url": url})). WithLogger(logrus.WithFields(logrus.Fields{"url": url})).
Download(ctx) Download(ctx, url)
if err != nil { if err != nil {
return false, err return false, err
} }