mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-03 11:04:28 -05:00
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.
This commit is contained in:
1 parent
afdaace67a
commit
8e508e56c2
8 files changed
+15
-15
No files matched your search
@@ -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%%"`
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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%%"`
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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`.
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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%%"`
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user