Skip to content

Commit

Permalink
storage: move storage file into config dir
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi4 committed Nov 10, 2024
1 parent 489f4a9 commit b892e5a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package storage
import (
"encoding/gob"
"os"
"os/user"
"path/filepath"

"github.com/getsavvyinc/savvy-cli/client"
"github.com/getsavvyinc/savvy-cli/config"
)

const defaultLocalDBDir = ".savvy"
const defaultDBFilename = "savvy.local"

var defaultLocalDBPath = filepath.Join(defaultLocalDBDir, defaultDBFilename)
var defaultLocalDBPath = filepath.Join(config.DefaultConfigDir, defaultDBFilename)

func Write(store map[string]*client.Runbook) error {
f, err := openStore()
Expand Down Expand Up @@ -55,13 +54,5 @@ func Read() (map[string]*client.Runbook, error) {
}

func openStore() (*os.File, error) {
u, err := user.Current()
if err != nil {
return nil, err
}
homeDir := u.HomeDir

storageFile := filepath.Join(homeDir, defaultLocalDBDir, defaultDBFilename)

return os.OpenFile(storageFile, os.O_RDWR|os.O_CREATE, 0666)
return os.OpenFile(defaultLocalDBPath, os.O_RDWR|os.O_CREATE, 0666)
}

0 comments on commit b892e5a

Please sign in to comment.