From 7a4fc3491a3809e008b32247cdedf2312471001d Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Wed, 8 Jan 2025 09:40:06 -0600 Subject: [PATCH] Ensure config directory is created. --- config.go | 16 ++++++++-------- main.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index 94a1b82..4967824 100644 --- a/config.go +++ b/config.go @@ -112,6 +112,14 @@ func ConfigPath() (fileDir, fileName string) { if flags.ConfigPath != "" { fileDir, fileName = filepath.Split(flags.ConfigPath) } + + // Verify directory exists. + if _, ferr := os.Stat(fileDir); ferr != nil { + err := os.MkdirAll(fileDir, 0755) + if err != nil { + log.Error("Failed to make directory:", err) + } + } return } @@ -481,14 +489,6 @@ func SaveConfig() error { // Find the file name. fileDir, fileName := ConfigPath() - // Verify directory exists. - if _, ferr := os.Stat(fileDir); ferr != nil { - err = os.MkdirAll(fileDir, 0755) - if err != nil { - log.Error("Failed to make directory:", err) - } - } - // Write the configuration file. err = os.WriteFile(filepath.Join(fileDir, fileName), data, 0644) return err diff --git a/main.go b/main.go index 8610f57..762316d 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ const ( serviceDisplayName = "Virtual VXLAN" serviceVendor = "com.mrgeckosmedia" serviceDescription = "Virtual VXLAN using TUN interfaces" - serviceVersion = "0.1.5" + serviceVersion = "0.1.6" defaultConfigFile = "config.yaml" )