create dirs if they do not exist
This commit is contained in:
Vendored
+4
@@ -5,6 +5,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Cache) nextMirror() string {
|
func (c *Cache) nextMirror() string {
|
||||||
@@ -33,6 +34,9 @@ func downloadToDisk(url, destPath string, c http.Client) error {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
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
|
// use a tmp file for the initial fetch in case it fails
|
||||||
tempPath := destPath + ".tmp"
|
tempPath := destPath + ".tmp"
|
||||||
tmpFile, err := os.Create(tempPath)
|
tmpFile, err := os.Create(tempPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user