Skip to content

Commit 9de7a3a

Browse files
committed
added basic cache partitioning
1 parent 42b480e commit 9de7a3a

5 files changed

Lines changed: 397 additions & 391 deletions

File tree

pkg/downloader/downloader.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ func (d *Downloader) Download(ctx context.Context, src string) (string, error) {
3030

3131
// download the file to a predictable location so that
3232
// we can avoid repeated downloads
33-
dst := filepath.Join(d.cacheDir, filepath.Base(uri.Path))
33+
dst := filepath.Join(d.cacheDir, uri.Hostname(), filepath.Base(uri.Path))
34+
// create the parent directory so that we don't
35+
// have any name clashes between different repositories
36+
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
37+
log.Error(err, "failed to create parent directory", "dir", filepath.Dir(dst))
38+
return "", err
39+
}
3440
log.V(1).Info("downloading file", "src", src, "dst", dst)
3541

3642
if _, err := os.Stat(dst); !os.IsNotExist(err) {

0 commit comments

Comments
 (0)