Create data subfolders on disk repo start
This commit is contained in:
@@ -25,6 +25,19 @@ type DiskRepo struct {
|
|||||||
|
|
||||||
// NewDiskRepo creates a new disk repo
|
// NewDiskRepo creates a new disk repo
|
||||||
func NewDiskRepo(serviceID string, cfg *config.Config, log olog.Logger) DiskRepo {
|
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{
|
return DiskRepo{
|
||||||
serviceID: serviceID,
|
serviceID: serviceID,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
|||||||
Reference in New Issue
Block a user