diff --git a/cmd/osbuild-jobsite-manager/main.go b/cmd/osbuild-jobsite-manager/main.go index fcb1c6218..4255c1fa7 100644 --- a/cmd/osbuild-jobsite-manager/main.go +++ b/cmd/osbuild-jobsite-manager/main.go @@ -13,6 +13,7 @@ import ( "os" "os/signal" "path" + "path/filepath" "syscall" "time" @@ -366,6 +367,16 @@ func StepExport() error { return } + dstPath := path.Join(argOutputPath, export) + dstDir := filepath.Dir(dstPath) + + if _, err := os.Stat(dstDir); os.IsNotExist(err) { + logrus.Infof("StepExport: Destination directory does not exist. Creating %s", dstDir) + if err := os.MkdirAll(dstDir, 0700); err != nil { + errs <- fmt.Errorf("StepExport: Failed to create destination directory: %s", err) + } + } + dst, err := os.OpenFile( path.Join(argOutputPath, export), os.O_WRONLY|os.O_CREATE|os.O_EXCL,