Skip to content

Commit

Permalink
Init dag dir (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
HtcOrange authored Mar 14, 2024
1 parent cc1b134 commit 4cb2e42
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/persistence/client/store_factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
"os"

"github.com/dagu-dev/dagu/internal/config"
"github.com/dagu-dev/dagu/internal/persistence"
"github.com/dagu-dev/dagu/internal/persistence/jsondb"
Expand All @@ -15,9 +17,22 @@ type dataStoreFactoryImpl struct {
var _ persistence.DataStoreFactory = (*dataStoreFactoryImpl)(nil)

func NewDataStoreFactory(cfg *config.Config) persistence.DataStoreFactory {
return &dataStoreFactoryImpl{
ds := &dataStoreFactoryImpl{
cfg: cfg,
}
_ = ds.InitDagDir()
return ds
}

func (f dataStoreFactoryImpl) InitDagDir() error {
_, err := os.Stat(f.cfg.DAGs)
if os.IsNotExist(err) {
if err := os.MkdirAll(f.cfg.DAGs, 0755); err != nil {
return err
}
}

return nil
}

func (f dataStoreFactoryImpl) NewHistoryStore() persistence.HistoryStore {
Expand Down

0 comments on commit 4cb2e42

Please sign in to comment.