Read the thumbnail input size limit in the same order as the generator

With both the old and the new name set, webdav and the thumbnails service picked different values.
This commit is contained in:
André Duffeck committed 2026-10-23 14:18:36 +02:00
1 parent 658688d18e
commit 46982c265a
4 files changed
+66 -2

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ Nothing has to be set in the single binary. The URL may also point at a real
| Old name | Now | |
| --- | --- | --- |
| `THUMBNAILS_RESOLUTIONS` | `WEBDAV_THUMBNAILS_RESOLUTIONS` | a ladder of edge lengths, not a list of boxes |
| `THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` | `OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` | read by webdav and the generator, which have to agree |
| `THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` | `OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE` | read by webdav and the generator, which have to agree; the old name still wins over the new one in both, so drop it when setting the new one |
| `THUMBNAILS_TXT_FONTMAP_FILE` | `WEBDAV_THUMBNAILS_TXT_FONTMAP_FILE` | webdav renders text before it posts |
| `THUMBNAILS_FILESYSTEMSTORAGE_ROOT` | `WEBDAV_THUMBNAILS_CACHE_DIR` | the old name is the directory that holds `files/`, the new one is the directory itself |
+1 -1
View File
@@ -38,7 +38,7 @@ type Config struct {
type Thumbnails struct {
GeneratorURL string `yaml:"generator_url" env:"WEBDAV_THUMBNAILS_GENERATOR_URL" desc:"Base URL of the thumbnail generator service, e.g. http://thumbnails:9186" introductionVersion:"%%NEXT%%"`
GeneratorTimeout string `yaml:"generator_timeout" env:"WEBDAV_THUMBNAILS_GENERATOR_TIMEOUT" desc:"HTTP timeout for requests to the thumbnail generator, e.g. 30s" introductionVersion:"%%NEXT%%"`
MaxInputFileSize string `yaml:"max_input_image_file_size" env:"THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" desc:"Maximum file size of an input image a thumbnail is made of. The generator refuses a larger body, so both read the same name by default. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB], example: 50MB" introductionVersion:"%%NEXT%%"`
MaxInputFileSize string `yaml:"max_input_image_file_size" env:"OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE;WEBDAV_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE" desc:"Maximum file size of an input image a thumbnail is made of. The generator refuses a larger body, so both read the same name by default. Usable common abbreviations: [KB, KiB, MB, MiB, GB, GiB], example: 50MB" introductionVersion:"%%NEXT%%"`
CacheBackend string `yaml:"cache_backend" env:"WEBDAV_THUMBNAILS_CACHE_BACKEND" desc:"Cache backend for imagor thumbnails: 'none', 'memory', 'file', or 's3'. Default: file." introductionVersion:"%%NEXT%%"`
CacheDir string `yaml:"cache_dir" env:"WEBDAV_THUMBNAILS_CACHE_DIR" desc:"Directory for file-based thumbnail cache (Default: $OC_BASE_DATA_PATH/thumbnails/files). Only used when WEBDAV_THUMBNAILS_CACHE_BACKEND is 'file'." introductionVersion:"%%NEXT%%"`
@@ -0,0 +1,48 @@
// Copyright 2026 OpenCloud GmbH <mail@opencloud.eu>
// SPDX-License-Identifier: Apache-2.0
package parser_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
thumbnailsdefaults "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config/defaults"
thumbnailsparser "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config/parser"
"github.com/opencloud-eu/opencloud/services/webdav/pkg/config/defaults"
"github.com/opencloud-eu/opencloud/services/webdav/pkg/config/parser"
)
var _ = Describe("ParseConfig", func() {
BeforeEach(func() {
GinkgoT().Setenv("OC_CONFIG_DIR", GinkgoT().TempDir())
})
// a body webdav allows and the generator refuses is downloaded and posted for nothing
DescribeTable("reads the maximum input file size the way the thumbnails service does",
func(env map[string]string, want string) {
for k, v := range env {
GinkgoT().Setenv(k, v)
}
cfg := defaults.DefaultConfig()
Expect(parser.ParseConfig(cfg)).To(Succeed())
generator := thumbnailsdefaults.DefaultConfig()
Expect(thumbnailsparser.ParseConfig(generator)).To(Succeed())
Expect(cfg.Thumbnails.MaxInputFileSize).To(Equal(want))
Expect(generator.Thumbnail.MaxInputImageFileSize).To(Equal(want))
},
Entry("from the shared name", map[string]string{
"OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE": "100MB",
}, "100MB"),
Entry("from the old name", map[string]string{
"THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE": "20MB",
}, "20MB"),
Entry("from the old name when both are set", map[string]string{
"THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE": "20MB",
"OC_THUMBNAILS_MAX_INPUT_IMAGE_FILE_SIZE": "100MB",
}, "20MB"),
)
})
@@ -0,0 +1,16 @@
// Copyright 2026 OpenCloud GmbH <mail@opencloud.eu>
// SPDX-License-Identifier: Apache-2.0
package parser_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestParser(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Parser Suite")
}