From b4486ada26e905c62f50bb158cd20544650f1569 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Tue, 5 May 2026 15:02:07 -0600 Subject: [PATCH] create dirs if they do not exist --- internal/cache/helpers.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/cache/helpers.go b/internal/cache/helpers.go index cb88955..543948e 100644 --- a/internal/cache/helpers.go +++ b/internal/cache/helpers.go @@ -5,6 +5,7 @@ import ( "log/slog" "net/http" "os" + "path/filepath" ) func (c *Cache) nextMirror() string { @@ -33,6 +34,9 @@ func downloadToDisk(url, destPath string, c http.Client) error { } defer resp.Body.Close() + // make sure the dir structure exists + os.MkdirAll(filepath.Dir(destPath), 0755) + // use a tmp file for the initial fetch in case it fails tempPath := destPath + ".tmp" tmpFile, err := os.Create(tempPath)