Skip to content

Commit 50df2b7

Browse files
original-brownbearfjl
authored andcommitted
console: create datadir at startup (ethereum#15700)
Fixes ethereum#15672 by creating the datadir when creating the console. This prevents failing to save the history if no datadir exists.
1 parent c786f75 commit 50df2b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

console/console.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func New(config Config) (*Console, error) {
9292
printer: config.Printer,
9393
histPath: filepath.Join(config.DataDir, HistoryFile),
9494
}
95+
if err := os.MkdirAll(config.DataDir, 0700); err != nil {
96+
return nil, err
97+
}
9598
if err := console.init(config.Preload); err != nil {
9699
return nil, err
97100
}
@@ -423,7 +426,7 @@ func (c *Console) Execute(path string) error {
423426
return c.jsre.Exec(path)
424427
}
425428

426-
// Stop cleans up the console and terminates the runtime envorinment.
429+
// Stop cleans up the console and terminates the runtime environment.
427430
func (c *Console) Stop(graceful bool) error {
428431
if err := ioutil.WriteFile(c.histPath, []byte(strings.Join(c.history, "\n")), 0600); err != nil {
429432
return err

0 commit comments

Comments
 (0)