From dc8689c26bec56fff9a39b48d74389095333dbee Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Tue, 19 Sep 2023 13:56:21 -0600 Subject: [PATCH] Added check for scanned database directory --- cmd/scan.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/scan.go b/cmd/scan.go index 8f7f4cf..5f3147c 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -2,6 +2,8 @@ package cmd import ( "fmt" + "os" + "path" magellan "github.com/bikeshack/magellan/internal" "github.com/bikeshack/magellan/internal/db/sqlite" @@ -46,6 +48,13 @@ var scanCmd = &cobra.Command{ for _, r := range probeStates { fmt.Printf("%s:%d (%s)\n", r.Host, r.Port, r.Protocol) } + + // make the dbpath dir if needed + err := os.MkdirAll(path.Dir(dbpath), 0766) + if err != nil { + fmt.Printf("could not make database directory: %v", err) + } + sqlite.InsertProbeResults(dbpath, &probeStates) }, }