Skip to content

Commit

Permalink
Ensure a target directory exists prior to downloading files (#909)
Browse files Browse the repository at this point in the history
## Description
Prevent file download failure when the target directory does not exist

Fixes #901
  • Loading branch information
jeff-mccoy authored Oct 13, 2022
1 parent c0708f1 commit 20cf67d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/internal/utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func Fetch(url string) io.ReadCloser {

func DownloadToFile(url string, target string, cosignKeyPath string) {

// Always ensure the target directory exists
if err := CreateFilePath(target); err != nil {
message.Fatalf(err, "Unable to create file path: %s", target)
}

// Create the file
destinationFile, err := os.Create(target)
if err != nil {
Expand Down

0 comments on commit 20cf67d

Please sign in to comment.