Skip to content

Commit

Permalink
SCR #0 - fix create default dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Tsurkan committed Jun 28, 2024
1 parent dcfb6e1 commit b620214
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/crypto/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"
"path/filepath"
"time"

"github.com/sirupsen/logrus"
)

type vault struct {
Expand Down Expand Up @@ -83,6 +85,22 @@ func backupVault() bool {

}

func CreateDirs() {
homeDir := os.Getenv("HOME")
filePath := filepath.Join(homeDir, ".local", "share", "go2fa")
err := os.MkdirAll(filepath.Join(filePath, "stores"), os.ModePerm)

if err != nil {
logrus.Fatal(err)
}

err = os.MkdirAll(filepath.Join(filePath, "backups"), os.ModePerm)

if err != nil {
logrus.Fatal(err)
}
}

func GetEmptyVault() vault {
return vault{}
}
Expand Down
1 change: 1 addition & 0 deletions internal/vault/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vault
import "go2fa/internal/crypto"

func Create() bool {
crypto.CreateDirs()
vault := crypto.GetEmptyVault()
crypto.GeneratePublicPrivateKeys()
crypto.SetEmptyVault(vault)
Expand Down

0 comments on commit b620214

Please sign in to comment.