create dirs if they do not exist
This commit is contained in:
Vendored
+4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user