diff --git a/internal/build/source_downloader.go b/internal/build/source_downloader.go index 7b38be4..bf5f9d6 100644 --- a/internal/build/source_downloader.go +++ b/internal/build/source_downloader.go @@ -74,7 +74,7 @@ func (s *SourceDownloader) DownloadSources( } } - opts.DlCache = dlcache.New(s.cfg) + opts.DlCache = dlcache.New(s.cfg.GetPaths().CacheDir) err := dl.Download(ctx, opts) if err != nil { diff --git a/pkg/dl/dl_test.go b/pkg/dl/dl_test.go index c7326b8..6022c71 100644 --- a/pkg/dl/dl_test.go +++ b/pkg/dl/dl_test.go @@ -155,7 +155,7 @@ func TestDownloadFileWithCache(t *testing.T) { CacheDisabled: false, URL: server.URL + "/file", Destination: tmpdir, - DlCache: dlcache.New(cfg), + DlCache: dlcache.New(cfg.GetPaths().CacheDir), } outputFile := path.Join(tmpdir, "file") diff --git a/pkg/dlcache/dlcache.go b/pkg/dlcache/dlcache.go index ccd654f..2462f68 100644 --- a/pkg/dlcache/dlcache.go +++ b/pkg/dlcache/dlcache.go @@ -32,19 +32,15 @@ type Config interface { } type DownloadCache struct { - cfg Config + cacheDir string } -func New(cfg Config) *DownloadCache { - return &DownloadCache{ - cfg, - } +func New(cacheDir string) *DownloadCache { + return &DownloadCache{cacheDir} } func (dc *DownloadCache) BasePath(ctx context.Context) string { - return filepath.Join( - dc.cfg.GetPaths().CacheDir, "dl", - ) + return filepath.Join(dc.cacheDir, "dl") } // New creates a new directory with the given ID in the cache. diff --git a/pkg/dlcache/dlcache_test.go b/pkg/dlcache/dlcache_test.go index 555cdba..247bad6 100644 --- a/pkg/dlcache/dlcache_test.go +++ b/pkg/dlcache/dlcache_test.go @@ -64,7 +64,7 @@ func TestNew(t *testing.T) { cfg := prepare(t) defer cleanup(t, cfg) - dc := dlcache.New(cfg) + dc := dlcache.New(cfg.GetPaths().CacheDir) ctx := context.Background()