From 52351d2c7ea3c702b26fc82ce389f0acd5db6721 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Tue, 29 Sep 2020 16:30:10 +0200 Subject: [PATCH] Create data subfolders on disk repo start --- accounts/pkg/storage/disk.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/accounts/pkg/storage/disk.go b/accounts/pkg/storage/disk.go index 1c7f21e203f..09e037d5e78 100644 --- a/accounts/pkg/storage/disk.go +++ b/accounts/pkg/storage/disk.go @@ -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,