Skip to content

Commit 542478f

Browse files
committed
stop erroring if node dir already exists
1 parent 2c01ce2 commit 542478f

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

local/helpers.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/ava-labs/avalanchego/config"
1515
"github.com/ava-labs/avalanchego/utils/constants"
1616
"github.com/ava-labs/avalanchego/utils/logging"
17-
"go.uber.org/zap"
1817
)
1918

2019
func init() {
@@ -194,28 +193,23 @@ func getPort(
194193
return port, nil
195194
}
196195

197-
func makeNodeDir(log logging.Logger, rootDir, nodeName string) (string, error) {
196+
func setNodeDir(log logging.Logger, rootDir, nodeName string) (string, error) {
198197
if rootDir == "" {
199198
log.Warn("no network root directory defined; will create this node's runtime directory in working directory")
200199
}
201200
// [nodeRootDir] is where this node's config file, C-Chain config file,
202201
// staking key, staking certificate and genesis file will be written.
203202
// (Other file locations are given in the node's config file.)
204203
// TODO should we do this for other directories? Profiles?
205-
nodeRootDir := getNodeDir(rootDir, nodeName)
204+
nodeRootDir := filepath.Join(rootDir, nodeName)
206205
if err := os.Mkdir(nodeRootDir, 0o755); err != nil {
207206
if !os.IsExist(err) {
208-
return "", fmt.Errorf("error creating temp dir %w", err)
207+
return "", fmt.Errorf("error creating node %s dir: %w", nodeRootDir, err)
209208
}
210-
log.Warn("node root directory already exists", zap.String("root-dir", nodeRootDir))
211209
}
212210
return nodeRootDir, nil
213211
}
214212

215-
func getNodeDir(rootDir string, nodeName string) string {
216-
return filepath.Join(rootDir, nodeName)
217-
}
218-
219213
// createFileAndWrite creates a file with the given path and
220214
// writes the given contents
221215
func createFileAndWrite(path string, contents []byte) error {

local/network.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ func (ln *localNetwork) addNode(nodeConfig node.Config) (node.Node, error) {
532532

533533
isPausedNode := ln.isPausedNode(&nodeConfig)
534534

535-
nodeDir, err := makeNodeDir(ln.log, ln.rootDir, nodeConfig.Name)
535+
nodeDir, err := setNodeDir(ln.log, ln.rootDir, nodeConfig.Name)
536536
if err != nil {
537537
return nil, err
538538
}

0 commit comments

Comments
 (0)