arcast/pkg/config/custom_files.go
William Petit 768393adc8
Some checks reported warnings
arcad/arcast/pipeline/head This commit is unstable
feat: allow homepage customization
2024-04-26 12:12:15 +02:00

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
}