Fix config dir creation on windows

This commit is contained in:
Bernd Schoolmann 2024-02-03 23:15:29 +01:00
parent e0cb8a9187
commit 1455cf9cb2
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -471,7 +471,10 @@ func (config *Config) WriteConfig() error {
os.Remove(config.ConfigFile.RuntimeConfig.ConfigDirectory) os.Remove(config.ConfigFile.RuntimeConfig.ConfigDirectory)
parentDirectory := config.ConfigFile.RuntimeConfig.ConfigDirectory[:len(config.ConfigFile.RuntimeConfig.ConfigDirectory)-len("/goldwarden.json")] parentDirectory := config.ConfigFile.RuntimeConfig.ConfigDirectory[:len(config.ConfigFile.RuntimeConfig.ConfigDirectory)-len("/goldwarden.json")]
if _, err := os.Stat(parentDirectory); os.IsNotExist(err) { if _, err := os.Stat(parentDirectory); os.IsNotExist(err) {
os.Mkdir(parentDirectory, 0700) err := os.MkdirAll(parentDirectory, 0700)
if err != nil {
return err
}
} }
file, err := os.OpenFile(config.ConfigFile.RuntimeConfig.ConfigDirectory, os.O_CREATE|os.O_WRONLY, 0600) file, err := os.OpenFile(config.ConfigFile.RuntimeConfig.ConfigDirectory, os.O_CREATE|os.O_WRONLY, 0600)