Config: Allow to increase the resolution limit at your own risk
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
38b2f8181a
commit
a67cb10055
5 changed files with 13 additions and 11 deletions
2
go.mod
2
go.mod
|
@ -37,7 +37,7 @@ require (
|
|||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
|
||||
github.com/sevlyar/go-daemon v0.1.6
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2
|
||||
github.com/tensorflow/tensorflow v1.15.2
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
|
|
2
go.sum
2
go.sum
|
@ -388,6 +388,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2 h1:VsBj3UD2xyAOu7kJw6O/2jjG2UXLFoBzihqDU9Ofg9M=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20230203202212-3282f94193f2/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/tensorflow/tensorflow v1.15.2 h1:7/f/A664Tml/nRJg04+p3StcrsT53mkcvmxYHXI21Qo=
|
||||
|
|
|
@ -14,11 +14,11 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/klauspost/cpuid/v2"
|
||||
"github.com/pbnjay/memory"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -732,13 +732,13 @@ func (c *Config) OriginalsByteLimit() int64 {
|
|||
|
||||
// ResolutionLimit returns the maximum resolution of originals in megapixels (width x height).
|
||||
func (c *Config) ResolutionLimit() int {
|
||||
if c.NoSponsor() {
|
||||
return DefaultResolutionLimit
|
||||
}
|
||||
|
||||
result := c.options.ResolutionLimit
|
||||
|
||||
if result <= 0 {
|
||||
// Disabling or increasing the limit is at your own risk.
|
||||
// Only sponsors receive support in case of problems.
|
||||
if result == 0 {
|
||||
return DefaultResolutionLimit
|
||||
} else if result < 0 {
|
||||
return -1
|
||||
} else if result > 900 {
|
||||
result = 900
|
||||
|
|
|
@ -381,17 +381,17 @@ func TestConfig_OriginalsByteLimit(t *testing.T) {
|
|||
func TestConfig_ResolutionLimit(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
|
||||
assert.Equal(t, -1, c.ResolutionLimit())
|
||||
assert.Equal(t, DefaultResolutionLimit, c.ResolutionLimit())
|
||||
c.options.ResolutionLimit = 800
|
||||
assert.Equal(t, 800, c.ResolutionLimit())
|
||||
c.options.ResolutionLimit = 950
|
||||
assert.Equal(t, 900, c.ResolutionLimit())
|
||||
c.options.ResolutionLimit = 0
|
||||
assert.Equal(t, -1, c.ResolutionLimit())
|
||||
assert.Equal(t, DefaultResolutionLimit, c.ResolutionLimit())
|
||||
c.options.ResolutionLimit = -1
|
||||
assert.Equal(t, -1, c.ResolutionLimit())
|
||||
c.options.Sponsor = false
|
||||
assert.Equal(t, 150, c.ResolutionLimit())
|
||||
assert.Equal(t, -1, c.ResolutionLimit())
|
||||
c.options.Sponsor = true
|
||||
assert.Equal(t, -1, c.ResolutionLimit())
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ var Flags = CliFlags{
|
|||
Value: DefaultResolutionLimit,
|
||||
Usage: "maximum resolution of media files in `MEGAPIXELS` (1-900; -1 to disable)",
|
||||
EnvVar: "PHOTOPRISM_RESOLUTION_LIMIT",
|
||||
}, Tags: []string{EnvSponsor}}, {
|
||||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
Name: "storage-path, s",
|
||||
Usage: "writable storage `PATH` for sidecar, cache, and database files",
|
||||
|
|
Loading…
Add table
Reference in a new issue