Skip to content

Commit

Permalink
creatrd a fallback to ./ for tests
Browse files Browse the repository at this point in the history
This should be handled by parameter but this is a quick workaround
  • Loading branch information
ehsan6sha committed Nov 1, 2023
1 parent 27269cd commit 0404eb1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions blockchain/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ func NewSimpleKeyStorer(dbPath string) *SimpleKeyStorer {
dbPath = "/internal/.secrets"
}

// Create the directory if it doesn't exist
// Try to create the directory
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
err := os.MkdirAll(dbPath, 0755)
if err != nil {
panic("Failed to create directory: " + err.Error())
// Fallback to a local directory
dbPath = "./internal/.secrets"
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
err = os.MkdirAll(dbPath, 0755)
if err != nil {
panic("Failed to create fallback directory: " + err.Error())
}
}
}
}

Expand Down

0 comments on commit 0404eb1

Please sign in to comment.