From 8e508e56c2746ee4cd6bc0c48bbc704c1c5b03be Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 23 Oct 2026 10:18:30 +0200 Subject: [PATCH] refactor: name the settings that extend a default list additional_* They are merged onto the built-in defaults, the way the proxy's additional_policies and OC_ADD_RUN_SERVICES are, so the name says it: env variable, yaml key and field all carry the prefix. The two that take key:value entries are named in the plural like the other map-shaped settings in this repo, and the README says which of the three takes bare mime types. --- services/frontend/pkg/config/config.go | 2 +- services/frontend/pkg/revaconfig/config.go | 2 +- services/graph/pkg/config/config.go | 2 +- services/graph/pkg/service/v0/service.go | 2 +- services/webdav/MIGRATION.md | 2 +- services/webdav/README.md | 8 ++++---- services/webdav/pkg/config/config.go | 6 +++--- services/webdav/pkg/service/v0/service.go | 6 +++--- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/services/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index f57f90949b..a64c55c0e7 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -232,5 +232,5 @@ type Groupware struct { // Thumbnails is what oc:has-preview is answered with. The names match the ones // the webdav service uses for the same list. type Thumbnails struct { - SourceTypes []string `yaml:"source_types" env:"OC_THUMBNAILS_SOURCE_TYPES;FRONTEND_THUMBNAILS_SOURCE_TYPES" desc:"Additional mime types oc:has-preview is answered with 1 for, the same list the webdav service attempts previews for. The types the build ships are included; this only adds to them." introductionVersion:"%%NEXT%%"` + AdditionalSourceTypes []string `yaml:"additional_source_types" env:"OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES;FRONTEND_THUMBNAILS_ADDITIONAL_SOURCE_TYPES" desc:"Additional mime types oc:has-preview is answered with 1 for, the same list the webdav service attempts previews for. The types the build ships are included; this only adds to them." introductionVersion:"%%NEXT%%"` } diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index b1ce4896d3..537b14524c 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -372,7 +372,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string "public_url": cfg.OCDav.PublicURL, // what oc:has-preview is answered from, the same set the // webdav service attempts previews for - "preview_mime_types": thumbnail.NewSourceTypes(cfg.OCDav.Thumbnails.SourceTypes).List(), + "preview_mime_types": thumbnail.NewSourceTypes(cfg.OCDav.Thumbnails.AdditionalSourceTypes).List(), // still not supported //"favorite_storage_driver": unused, //"favorite_storage_drivers": unused, diff --git a/services/graph/pkg/config/config.go b/services/graph/pkg/config/config.go index 04ea036801..cd8ea40f75 100644 --- a/services/graph/pkg/config/config.go +++ b/services/graph/pkg/config/config.go @@ -213,5 +213,5 @@ type Store struct { // Thumbnails is what this service announces a preview for. The names match the // ones the webdav service uses for the same list. type Thumbnails struct { - SourceTypes []string `yaml:"source_types" env:"OC_THUMBNAILS_SOURCE_TYPES;GRAPH_THUMBNAILS_SOURCE_TYPES" desc:"Additional mime types a preview is announced for, the same list the webdav service attempts previews for. The types the build ships are included; this only adds to them." introductionVersion:"%%NEXT%%"` + AdditionalSourceTypes []string `yaml:"additional_source_types" env:"OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES;GRAPH_THUMBNAILS_ADDITIONAL_SOURCE_TYPES" desc:"Additional mime types a preview is announced for, the same list the webdav service attempts previews for. The types the build ships are included; this only adds to them." introductionVersion:"%%NEXT%%"` } diff --git a/services/graph/pkg/service/v0/service.go b/services/graph/pkg/service/v0/service.go index e7abca22e6..65e0d39305 100644 --- a/services/graph/pkg/service/v0/service.go +++ b/services/graph/pkg/service/v0/service.go @@ -184,7 +184,7 @@ func NewService(opts ...Option) (Graph, error) { //nolint:maintidx svc := Graph{ BaseGraphService: baseGraphService, - sourceTypes: thumbnail.NewSourceTypes(options.Config.Thumbnails.SourceTypes), + sourceTypes: thumbnail.NewSourceTypes(options.Config.Thumbnails.AdditionalSourceTypes), mux: m, specialDriveItemsCache: spacePropertiesCache, eventsPublisher: options.EventsPublisher, diff --git a/services/webdav/MIGRATION.md b/services/webdav/MIGRATION.md index 3c76927ddc..35d1879575 100644 --- a/services/webdav/MIGRATION.md +++ b/services/webdav/MIGRATION.md @@ -97,5 +97,5 @@ file's type, so the cache is cold after the update and fills again as previews a requested. Nothing has to be deleted. Which types a preview is announced and attempted for is one list for webdav, graph -and the PROPFIND property, set through `OC_THUMBNAILS_SOURCE_TYPES`. A type the +and the PROPFIND property, set through `OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES`. A type the running generator cannot read answers `404`. diff --git a/services/webdav/README.md b/services/webdav/README.md index 2ebd79f80d..cfd83ac6f7 100644 --- a/services/webdav/README.md +++ b/services/webdav/README.md @@ -66,13 +66,13 @@ Without a processor two things decide, in this order. An unconstrained axis is a The thumbnails themselves are made by a generator the webdav service POSTs to, configured with `WEBDAV_THUMBNAILS_GENERATOR_URL` (and `WEBDAV_THUMBNAILS_GENERATOR_TIMEOUT`). The built-in thumbnails service speaks the imagor image endpoint, so a real [imagor](https://imagor.net) can be put in its place without changing anything else. A source the generator cannot read answers `404`, one that is too large `403`, and `WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` caps what is sent at all; `OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` sets this and the generator's own cap together, so one does not send what the other refuses. A generator that refuses because it is busy answers `429` with its own `Retry-After`, so a client can come back instead of treating it as a missing preview. The same cap bounds an image webdav extracts itself, the cover of an audio file or the thumbnail inside a geogebra container, because a compressed entry says nothing about its size until it is read. A cropping resize asks the generator for a smart crop, so what survives is the region that carries the image; a generator without libvips answers the same request with a centre crop. -Three settings say what is made of what. They are merged onto the built-in defaults, so naming one type does not take the answer away from the others: +Three settings say what is made of what. Each one is merged onto the built-in defaults, which is what their `ADDITIONAL` says: naming one type does not take the answer away from the others, and an entry for a type the defaults already answer for replaces that one entry. The first takes bare mime types, the other two take `key:value` entries: | Environment variable | Description | | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `OC_THUMBNAILS_SOURCE_TYPES` | Types a preview is announced and attempted for, e.g. `image/vnd.microsoft.icon` for a generator that reads icons. The webdav, graph and ocdav side all read this one name | -| `OC_THUMBNAILS_TYPE_MAPPING` | The type a thumbnail is returned in, per source type, as `mime:mime` entries, e.g. `image/vnd.microsoft.icon:image/png` | -| `OC_THUMBNAILS_GENERATOR_FORMATS` | The formats the generator writes, as `mime:format` entries, e.g. `image/webp:webp`. The format is the name its own `format(...)` filter uses | +| `OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES` | Types a preview is announced and attempted for, e.g. `image/vnd.microsoft.icon` for a generator that reads icons. The webdav, graph and ocdav side all read this one name | +| `OC_THUMBNAILS_ADDITIONAL_OUTPUT_TYPES` | The type a thumbnail is returned in, per source type, as `mime:mime` entries, e.g. `image/vnd.microsoft.icon:image/png` | +| `OC_THUMBNAILS_ADDITIONAL_GENERATOR_FORMATS` | The formats the generator writes, as `mime:format` entries, e.g. `image/webp:webp`. The format is the name its own `format(...)` filter uses | Reading them as a chain: a source type is mapped to the type its thumbnail is returned in, and that type is asked for by the name the generator knows it under. An icon becomes `image/png`, which the generator is asked for as `format(png)`. A type nobody mapped becomes a JPEG, and so does a mapping onto a type this service has no format name for: what a generator behind the URL really writes is its own business, and a wrong guess here must not keep the service from starting. diff --git a/services/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index 61874d8e87..dffe3ebd4b 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -50,10 +50,10 @@ type Thumbnails struct { CacheS3Endpoint string `yaml:"cache_s3_endpoint" env:"WEBDAV_THUMBNAILS_CACHE_S3_ENDPOINT" desc:"S3 endpoint URL (for MinIO or compatible services) when WEBDAV_THUMBNAILS_CACHE_BACKEND is 's3'." introductionVersion:"%%NEXT%%"` CacheS3AccessKey string `yaml:"cache_s3_access_key" env:"WEBDAV_THUMBNAILS_CACHE_S3_ACCESS_KEY" desc:"S3 access key for thumbnail cache authentication." introductionVersion:"%%NEXT%%"` CacheS3SecretKey string `yaml:"cache_s3_secret_key" env:"WEBDAV_THUMBNAILS_CACHE_S3_SECRET_KEY" desc:"S3 secret key for thumbnail cache authentication." introductionVersion:"%%NEXT%%"` - SourceTypes []string `yaml:"source_types" env:"OC_THUMBNAILS_SOURCE_TYPES;WEBDAV_THUMBNAILS_SOURCE_TYPES" desc:"Additional mime types a preview is announced and attempted for, e.g. image/vnd.microsoft.icon for a generator that reads icons. The built-in list is included; this only adds to them. A type the running generator cannot read answers 404." introductionVersion:"%%NEXT%%"` + AdditionalSourceTypes []string `yaml:"additional_source_types" env:"OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES;WEBDAV_THUMBNAILS_ADDITIONAL_SOURCE_TYPES" desc:"Additional mime types a preview is announced and attempted for, e.g. image/vnd.microsoft.icon for a generator that reads icons. The built-in list is included; this only adds to them. A type the running generator cannot read answers 404." introductionVersion:"%%NEXT%%"` - GeneratorFormats []string `yaml:"generator_formats" env:"OC_THUMBNAILS_GENERATOR_FORMATS;WEBDAV_THUMBNAILS_GENERATOR_FORMATS" desc:"The formats the thumbnail generator writes, as mime:format entries, e.g. image/webp:webp. The format is the name the generator's own format filter uses. A type that is not listed is asked for as a JPEG instead, because what the generator behind the URL really writes is its own business." introductionVersion:"%%NEXT%%"` - TypeMapping []string `yaml:"type_mapping" env:"OC_THUMBNAILS_TYPE_MAPPING;WEBDAV_THUMBNAILS_TYPE_MAPPING" desc:"The type a thumbnail is returned in, per type of the image it is made from, as mime:mime entries, e.g. image/vnd.microsoft.icon:image/png. The target is asked for by the name WEBDAV_THUMBNAILS_GENERATOR_FORMATS gives it. A type that is not listed becomes a JPEG; a target this service has no format name for is asked for as a JPEG as well." introductionVersion:"%%NEXT%%"` + AdditionalGeneratorFormats []string `yaml:"additional_generator_formats" env:"OC_THUMBNAILS_ADDITIONAL_GENERATOR_FORMATS;WEBDAV_THUMBNAILS_ADDITIONAL_GENERATOR_FORMATS" desc:"Additional formats the thumbnail generator writes, one per type it writes, as type:format entries, e.g. image/webp:webp. The format is the name the generator's own format filter uses. The built-in list is included; an entry for a type that is already listed replaces it. A type that is not listed is asked for as a JPEG instead, because what the generator behind the URL really writes is its own business." introductionVersion:"%%NEXT%%"` + AdditionalOutputTypes []string `yaml:"additional_output_types" env:"OC_THUMBNAILS_ADDITIONAL_OUTPUT_TYPES;WEBDAV_THUMBNAILS_ADDITIONAL_OUTPUT_TYPES" desc:"Additional types a thumbnail is returned in, one per type of the image it is made from, as source:target entries, e.g. image/vnd.microsoft.icon:image/png. The built-in list is included; an entry for a source type that is already listed replaces it. The target is asked for by the name WEBDAV_THUMBNAILS_ADDITIONAL_GENERATOR_FORMATS gives it. A type that is not listed becomes a JPEG; a target this service has no format name for is asked for as a JPEG as well." introductionVersion:"%%NEXT%%"` FontMapFile string `yaml:"txt_fontmap_file" env:"THUMBNAILS_TXT_FONTMAP_FILE;WEBDAV_THUMBNAILS_TXT_FONTMAP_FILE" desc:"The path to a font map file for txt thumbnails." introductionVersion:"%%NEXT%%"` } diff --git a/services/webdav/pkg/service/v0/service.go b/services/webdav/pkg/service/v0/service.go index 78d0e428dd..8308a79616 100644 --- a/services/webdav/pkg/service/v0/service.go +++ b/services/webdav/pkg/service/v0/service.go @@ -71,7 +71,7 @@ func NewService(opts ...Option) (Service, error) { ), ) - sourceTypes := thumbnail.NewSourceTypes(conf.Thumbnails.SourceTypes) + sourceTypes := thumbnail.NewSourceTypes(conf.Thumbnails.AdditionalSourceTypes) tm, err := pool.StringToTLSMode(conf.GRPCClientTLS.Mode) if err != nil { @@ -181,8 +181,8 @@ func newThumbnailWorkflow(conf *config.Config, sourceTypes thumbnail.SourceTypes return nil, fmt.Errorf("parse max input file size: %w", err) } - typeMapping := thumbnail.NewTypeMapping(conf.Thumbnails.TypeMapping) - formats := generator.NewFormats(conf.Thumbnails.GeneratorFormats) + typeMapping := thumbnail.NewTypeMapping(conf.Thumbnails.AdditionalOutputTypes) + formats := generator.NewFormats(conf.Thumbnails.AdditionalGeneratorFormats) s3cfg := cache.BuildS3CacheConfig( conf.Thumbnails.CacheS3Bucket,