From 0d38ccf20cbf84dc4fe118aae4b975042ba7f1a1 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 14 Mar 2022 10:16:16 -0500 Subject: [PATCH] Create boxes dir if it does not exist --- internal/core/basis.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/core/basis.go b/internal/core/basis.go index 2dc15aef6..cd717973f 100644 --- a/internal/core/basis.go +++ b/internal/core/basis.go @@ -3,6 +3,7 @@ package core import ( "context" "fmt" + "os" "path/filepath" "strings" "sync" @@ -292,10 +293,14 @@ func (b *Basis) State() *StateBag { func (b *Basis) Boxes() (bc core.BoxCollection, err error) { if b.boxCollection == nil { - b.boxCollection, err = NewBoxCollection(b, - filepath.Join(b.dir.DataDir().String(), "boxes"), - b.logger, - ) + boxesDir := filepath.Join(b.dir.DataDir().String(), "boxes") + if _, err := os.Stat(boxesDir); os.IsNotExist(err) { + err := os.MkdirAll(boxesDir, os.ModePerm) + if err != nil { + return nil, err + } + } + b.boxCollection, err = NewBoxCollection(b, boxesDir, b.logger) if err != nil { return nil, err }