aboutsummaryrefslogtreecommitdiffstats
path: root/console
diff options
context:
space:
mode:
authorArmin Braun <me@obrown.io>2017-12-19 20:21:03 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-12-19 20:21:03 +0800
commit50df2b78be038fceb6975582a5f07052de939cbc (patch)
treef684dc4267ce89fd7f26ef7a1c999dc3aeea24a4 /console
parentc786f75389121c29d4380c53a013759254457776 (diff)
downloadgo-tangerine-50df2b78be038fceb6975582a5f07052de939cbc.tar.gz
go-tangerine-50df2b78be038fceb6975582a5f07052de939cbc.tar.zst
go-tangerine-50df2b78be038fceb6975582a5f07052de939cbc.zip
console: create datadir at startup (#15700)
Fixes #15672 by creating the datadir when creating the console. This prevents failing to save the history if no datadir exists.
Diffstat (limited to 'console')
-rw-r--r--console/console.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/console/console.go b/console/console.go
index 1ecbfd0b0..52fe1f542 100644
--- a/console/console.go
+++ b/console/console.go
@@ -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
}
@@ -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