Create boxes dir if it does not exist

This commit is contained in:
sophia 2022-03-14 10:16:16 -05:00 committed by Paul Hinze
parent b3f8c5a99d
commit 0d38ccf20c
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -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
}