Skip to content

Commit

Permalink
Create data subfolders on disk repo start
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Sep 30, 2020
1 parent b051f98 commit 52351d2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions accounts/pkg/storage/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ type DiskRepo struct {

// NewDiskRepo creates a new disk repo
func NewDiskRepo(serviceID string, cfg *config.Config, log olog.Logger) DiskRepo {
paths := []string{
filepath.Join(cfg.Repo.Disk.Path, accountsFolder),
filepath.Join(cfg.Repo.Disk.Path, groupsFolder),
}
for i := range paths {
if _, err := os.Stat(paths[i]); err != nil {
if os.IsNotExist(err) {
if err = os.MkdirAll(paths[i], 0700); err != nil {
log.Fatal().Err(err).Msgf("could not create data folder %v", paths[i])
}
}
}
}
return DiskRepo{
serviceID: serviceID,
cfg: cfg,
Expand Down

0 comments on commit 52351d2

Please sign in to comment.