jobsite/manager: create export directory

Be a bit more friendly and actually create the export directory instead
of assuming it exists.
This commit is contained in:
Simon de Vlieger 2024-02-15 16:14:58 +01:00 committed by Sanne Raymaekers
parent 1150f0f27e
commit b9584099ab

View file

@ -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,