Fix generateKey error logging

This logs the actual error when it occurs, instead of always saying that
the key already exists.
This commit is contained in:
Matt Baer 2019-01-20 13:43:06 -05:00
parent cb1bd37f64
commit 1c40103fbf
1 changed files with 4 additions and 1 deletions

View File

@ -73,9 +73,12 @@ func initKeys(app *app) error {
// keys, this won't overwrite any existing key, and instead outputs a message.
func generateKey(path string) error {
// Check if key file exists
if _, err := os.Stat(path); !os.IsNotExist(err) {
if _, err := os.Stat(path); err == nil {
log.Info("%s already exists. rm the file if you understand the consquences.", path)
return nil
} else if !os.IsNotExist(err) {
log.Error("%s", err)
return err
}
log.Info("Generating %s.", path)