Skip to content

Commit

Permalink
Merge pull request #3179 from keep-network/ensure-app-dir-exists
Browse files Browse the repository at this point in the history
Ensure existence of the application storage directory

So far, the client exited with an error in case the appropriate storage directory 
for the beacon or tbtc application was missing. Here we check whether the storage 
directory exists, and we create a fresh one in case it is missing.
  • Loading branch information
nkuba authored Aug 19, 2022
2 parents a7520cf + 40102b5 commit 6b234e8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"context"
"fmt"

"github.com/keep-network/keep-core/pkg/tbtc"

"github.com/keep-network/keep-core/config"
Expand Down Expand Up @@ -142,6 +141,19 @@ func initializePersistence(clientConfig *config.Config, application string) (
persistence.Handle,
error,
) {
err := persistence.EnsureDirectoryExists(
clientConfig.Storage.DataDir,
application,
)
if err != nil {
return nil, fmt.Errorf(
"cannot create storage directory for "+
"application [%v]: [%w]",
application,
err,
)
}

path := fmt.Sprintf("%s/%s", clientConfig.Storage.DataDir, application)

diskHandle, err := persistence.NewDiskHandle(path)
Expand Down

0 comments on commit 6b234e8

Please sign in to comment.