Files
opencloud/services/webdav/pkg/config/parser/parse.go
T
Dominik Schmidt 17a9874be2 feat(webdav): make the Tika thumbnail preset configurable
OC_TIKA_THUMBNAIL_PRESET (WEBDAV_TIKA_THUMBNAIL_PRESET) names the catalog
preset webdav unpacks thumbnails with, "thumbnail" by default. A preset of
your own has to bring the same filter, only the raster images Tika marks as
THUMBNAIL or RENDERING, since webdav takes the first image in the answer.
An empty preset fails at startup.

Changing the preset needs the thumbnail cache emptied, as a Tika upgrade
does.
2026-12-02 16:22:19 +01:00

42 lines
1.0 KiB
Go

package parser
import (
"errors"
"strings"
occfg "github.com/opencloud-eu/opencloud/pkg/config"
"github.com/opencloud-eu/opencloud/services/webdav/pkg/config"
"github.com/opencloud-eu/opencloud/services/webdav/pkg/config/defaults"
"github.com/opencloud-eu/opencloud/pkg/config/envdecode"
)
// ParseConfig loads configuration from known paths.
func ParseConfig(cfg *config.Config) error {
err := occfg.BindSourcesToStructs(cfg.Service.Name, cfg)
if err != nil {
return err
}
defaults.EnsureDefaults(cfg)
// load all env variables relevant to the config in the current context.
if err := envdecode.Decode(cfg); err != nil {
// no environment variable set for this config is an expected "error"
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
return err
}
}
defaults.Sanitize(cfg)
return Validate(cfg)
}
func Validate(cfg *config.Config) error {
if strings.TrimSpace(cfg.TikaThumbnailPreset) == "" {
return errors.New("OC_TIKA_THUMBNAIL_PRESET must not be empty")
}
return nil
}