create dirs if they do not exist

This commit is contained in:
2026-05-05 15:02:07 -06:00
parent 616b8f1eac
commit b4486ada26
+4
View File
@@ -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)