Skip to content

Commit

Permalink
console: create datadir at startup (ethereum#15700)
Browse files Browse the repository at this point in the history
Fixes ethereum#15672 by creating the datadir when creating the
console. This prevents failing to save the history if no datadir
exists.
  • Loading branch information
original-brownbear authored and fjl committed Dec 19, 2017
1 parent c786f75 commit 50df2b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func New(config Config) (*Console, error) {
printer: config.Printer,
histPath: filepath.Join(config.DataDir, HistoryFile),
}
if err := os.MkdirAll(config.DataDir, 0700); err != nil {
return nil, err
}
if err := console.init(config.Preload); err != nil {
return nil, err
}
Expand Down Expand Up @@ -423,7 +426,7 @@ func (c *Console) Execute(path string) error {
return c.jsre.Exec(path)
}

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

0 comments on commit 50df2b7

Please sign in to comment.