Skip to content

Commit

Permalink
[addressBook] refs #313 - Change addressBook database path to QSettin…
Browse files Browse the repository at this point in the history
…g path.
  • Loading branch information
hsequeda committed Jan 13, 2020
1 parent 9710a39 commit a2c03f3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/models/addressBook/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/fibercrypto/fibercryptowallet/src/core"
"github.com/fibercrypto/fibercryptowallet/src/data"
"github.com/fibercrypto/fibercryptowallet/src/util/logging"
"github.com/skycoin/skycoin/src/util/file"
qtcore "github.com/therecipe/qt/core"
"github.com/therecipe/qt/qml"
"os"
Expand Down Expand Up @@ -78,6 +79,7 @@ func (abm *AddrsBookModel) init() {
abm.ConnectHasInit(abm.hasInit)
abm.ConnectChangeSecType(abm.changeSecType)
abm.ConnectAddAddress(abm.addAddress)
logAddressBook.Infof("%s,\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", getConfigFileDir())
if addrsBook == nil {
db, err := data.GetBoltStorage(getConfigFileDir())
if err != nil {
Expand Down Expand Up @@ -185,8 +187,19 @@ func (abm *AddrsBookModel) editContact(row int, id uint64, name string) {
}

func getConfigFileDir() string {
homeDir := os.Getenv("HOME")
fileDir := filepath.Join(homeDir, ".fiber/data.dt")
qSettingDir := qtcore.NewQSettings(qtcore.QCoreApplication_OrganizationName(), qtcore.QCoreApplication_ApplicationName(), nil).FileName()
path, _ := filepath.Split(qSettingDir)
ok, err := file.Exists(path)
if err != nil {
logAddressBook.WithError(err).Warn("getting file dir")
}
if !ok {
if err := os.Mkdir(path, 0777); err != nil {
logAddressBook.WithError(err).Warn("getting file dir")
}
}

fileDir := filepath.Join(path, "data.dt")
return fileDir
}

Expand Down

0 comments on commit a2c03f3

Please sign in to comment.