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)