29 lines
577 B
Go
29 lines
577 B
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/pkg/errors"
|
|
"gitlab.com/wpetit/goweb/logger"
|
|
)
|
|
|
|
func CreateCustomDir(ctx context.Context, filename string, conf *Config) error {
|
|
if conf.HTTP.CustomDir != "" {
|
|
return nil
|
|
}
|
|
|
|
configDir := filepath.Dir(filename)
|
|
customFilesDir := filepath.Join(configDir, "custom")
|
|
|
|
if err := os.MkdirAll(customFilesDir, 0755); err != nil {
|
|
logger.Error(ctx, "could not create custom files directory", logger.CapturedE(errors.WithStack(err)))
|
|
return nil
|
|
}
|
|
|
|
conf.HTTP.CustomDir = customFilesDir
|
|
|
|
return nil
|
|
}
|