Fix last createDir.

This commit is contained in:
cheatfate 2020-08-27 21:23:41 +03:00 committed by zah
parent 86139839f1
commit 82228fe471
5 changed files with 37 additions and 17 deletions

View File

@ -1262,8 +1262,15 @@ programMain:
swap(mnemonic, walletRes.get.mnemonic)
walletPath = walletRes.get.walletPath
createDir(config.outValidatorsDir)
createDir(config.outSecretsDir)
let vres = createPath(config.outValidatorsDir, 0o750)
if vres.isErr():
fatal "Could not create directory", path = config.outValidatorsDir
quit QuitFailure
let sres = createPath(config.outSecretsDir, 0o750)
if sres.isErr():
fatal "Could not create directory", path = config.outSecretsDir
quit QuitFailure
let deposits = generateDeposits(
config.runtimePreset,

View File

@ -5,7 +5,8 @@ import
chronicles, chronicles/options as chroniclesOptions,
confutils, confutils/defs, confutils/std/net, stew/shims/net as stewNet,
json_serialization, web3/[ethtypes, confutils_defs],
spec/[crypto, keystore, digest, datatypes, network], network_metadata
spec/[crypto, keystore, digest, datatypes, network], network_metadata,
stew/io2
export
defaultEth2TcpPort, enabledLogLevel, ValidIpAddress,
@ -440,13 +441,15 @@ func dumpDirOutgoing*(conf: BeaconNodeConf|ValidatorClientConf): string =
proc createDumpDirs*(conf: BeaconNodeConf) =
if conf.dumpEnabled:
try:
createDir(conf.dumpDirInvalid)
createDir(conf.dumpDirIncoming)
createDir(conf.dumpDirOutgoing)
except CatchableError as err:
# Dumping is mainly a debugging feature, so ignore these..
warn "Cannot create dump directories", msg = err.msg
let resInv = createPath(conf.dumpDirInvalid, 0o750)
if resInv.isErr():
warn "Could not create dump directory", path = conf.dumpDirInvalid
let resInc = createPath(conf.dumpDirIncoming, 0o750)
if resInc.isErr():
warn "Could not create dump directory", path = conf.dumpDirIncoming
let resOut = createPath(conf.dumpDirOutgoing, 0o750)
if resOut.isErr():
warn "Could not create dump directory", path = conf.dumpDirOutgoing
func parseCmdArg*(T: type GraffitiBytes, input: TaintedString): T
{.raises: [ValueError, Defect].} =

View File

@ -2,7 +2,7 @@ import
os, sequtils, strutils, options, json, terminal, random,
chronos, chronicles, confutils, stint, json_serialization,
../beacon_chain/network_metadata,
web3, web3/confutils_defs, eth/keys,
web3, web3/confutils_defs, eth/keys, stew/io2,
spec/[datatypes, crypto, presets], ssz/merkleization, keystore_management
# Compiled version of /scripts/depositContract.v.py in this repo
@ -178,8 +178,15 @@ proc main() {.async.} =
mnemonic = generateMnemonic(rng[])
runtimePreset = getRuntimePresetForNetwork(cfg.eth2Network)
createDir(string cfg.outValidatorsDir)
createDir(string cfg.outSecretsDir)
let vres = createPath(string cfg.outValidatorsDir, 0o750)
if vres.isErr():
warn "Could not create validators folder",
path = string cfg.outValidatorsDir, err = ioErrorMsg(vres.error)
let sres = createPath(string cfg.outSecretsDir, 0o750)
if sres.isErr():
warn "Could not create secrets folder",
path = string cfg.outSecretsDir, err = ioErrorMsg(sres.error)
let deposits = generateDeposits(
runtimePreset,

View File

@ -14,6 +14,7 @@ import
# Nimble packages
chronos, confutils/defs,
chronicles, chronicles/helpers as chroniclesHelpers,
stew/io2,
# Local modules
spec/[datatypes, crypto, helpers], eth2_network, time
@ -36,10 +37,10 @@ proc setupLogging*(logLevel: string, logFile: Option[OutFile]) =
let
logFile = logFile.get.string
logFileDir = splitFile(logFile).dir
try:
createDir logFileDir
except CatchableError as err:
error "Failed to create directory for log file", path = logFileDir, err = err.msg
let lres = createPath(logFileDir, 0o750)
if lres.isErr():
error "Failed to create directory for log file",
path = logFileDir, err = ioErrorMsg(lres.error)
break openLogFile
if not defaultChroniclesStream.outputs[1].open(logFile):

View File

@ -35,6 +35,8 @@ declareCounter beacon_blocks_proposed,
logScope: topics = "beacval"
# TODO: This procedure follows insecure scheme of creating directory without
# any permissions and writing file without any permissions.
proc saveValidatorKey*(keyName, key: string, conf: BeaconNodeConf) =
let validatorsDir = conf.validatorsDir
let outputFile = validatorsDir / keyName