Config: Update options report, parameter names and tests
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
22b7da8e34
commit
3b9890e345
20 changed files with 71 additions and 69 deletions
|
@ -54,7 +54,7 @@ func showOptionsAction(ctx *cli.Context) error {
|
|||
{Start: "PHOTOPRISM_READONLY", Title: "Feature Flags"},
|
||||
{Start: "PHOTOPRISM_DEFAULT_LOCALE", Title: "Customization"},
|
||||
{Start: "PHOTOPRISM_CDN_URL", Title: "Site Information"},
|
||||
{Start: "PHOTOPRISM_HTTP_PORT", Title: "Web Server"},
|
||||
{Start: "PHOTOPRISM_TRUSTED_PROXY", Title: "Web Server"},
|
||||
{Start: "PHOTOPRISM_DATABASE_DRIVER", Title: "Database Connection"},
|
||||
{Start: "PHOTOPRISM_DARKTABLE_BIN", Title: "File Converters"},
|
||||
{Start: "PHOTOPRISM_DOWNLOAD_TOKEN", Title: "Security Tokens"},
|
||||
|
|
|
@ -40,26 +40,26 @@ func (c *Config) AdminPassword() string {
|
|||
return clean.Password(c.options.AdminPassword)
|
||||
}
|
||||
|
||||
// SessMaxAge returns the time in seconds until browser sessions expire automatically.
|
||||
func (c *Config) SessMaxAge() int64 {
|
||||
if c.options.SessMaxAge < 0 {
|
||||
// SessionMaxAge returns the time in seconds until API sessions expire automatically.
|
||||
func (c *Config) SessionMaxAge() int64 {
|
||||
if c.options.SessionMaxAge < 0 {
|
||||
return 0
|
||||
} else if c.options.SessMaxAge == 0 {
|
||||
return DefaultSessMaxAge
|
||||
} else if c.options.SessionMaxAge == 0 {
|
||||
return DefaultSessionMaxAge
|
||||
}
|
||||
|
||||
return c.options.SessMaxAge
|
||||
return c.options.SessionMaxAge
|
||||
}
|
||||
|
||||
// SessTimeout returns the time in seconds until browser sessions expire due to inactivity
|
||||
func (c *Config) SessTimeout() int64 {
|
||||
if c.options.SessTimeout < 0 {
|
||||
// SessionTimeout returns the time in seconds until API sessions expire due to inactivity
|
||||
func (c *Config) SessionTimeout() int64 {
|
||||
if c.options.SessionTimeout < 0 {
|
||||
return 0
|
||||
} else if c.options.SessTimeout == 0 {
|
||||
return DefaultSessTimeout
|
||||
} else if c.options.SessionTimeout == 0 {
|
||||
return DefaultSessionTimeout
|
||||
}
|
||||
|
||||
return c.options.SessTimeout
|
||||
return c.options.SessionTimeout
|
||||
}
|
||||
|
||||
// Public checks if app runs in public mode and requires no authentication.
|
||||
|
|
|
@ -48,20 +48,20 @@ func TestAuth(t *testing.T) {
|
|||
|
||||
func TestSessMaxAge(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
assert.Equal(t, DefaultSessMaxAge, c.SessMaxAge())
|
||||
c.options.SessMaxAge = -1
|
||||
assert.Equal(t, int64(0), c.SessMaxAge())
|
||||
c.options.SessMaxAge = 0
|
||||
assert.Equal(t, DefaultSessMaxAge, c.SessMaxAge())
|
||||
assert.Equal(t, DefaultSessionMaxAge, c.SessionMaxAge())
|
||||
c.options.SessionMaxAge = -1
|
||||
assert.Equal(t, int64(0), c.SessionMaxAge())
|
||||
c.options.SessionMaxAge = 0
|
||||
assert.Equal(t, DefaultSessionMaxAge, c.SessionMaxAge())
|
||||
}
|
||||
|
||||
func TestSessTimeout(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
assert.Equal(t, DefaultSessTimeout, c.SessTimeout())
|
||||
c.options.SessTimeout = -1
|
||||
assert.Equal(t, int64(0), c.SessTimeout())
|
||||
c.options.SessTimeout = 0
|
||||
assert.Equal(t, DefaultSessTimeout, c.SessTimeout())
|
||||
assert.Equal(t, DefaultSessionTimeout, c.SessionTimeout())
|
||||
c.options.SessionTimeout = -1
|
||||
assert.Equal(t, int64(0), c.SessionTimeout())
|
||||
c.options.SessionTimeout = 0
|
||||
assert.Equal(t, DefaultSessionTimeout, c.SessionTimeout())
|
||||
}
|
||||
|
||||
func TestUtils_CheckPassword(t *testing.T) {
|
||||
|
|
|
@ -58,8 +58,8 @@ const UnixDay = UnixHour * 24
|
|||
// UnixWeek is one week in UnixTime.
|
||||
const UnixWeek = UnixDay * 7
|
||||
|
||||
// DefaultSessMaxAge is the default session expiration time in seconds.
|
||||
const DefaultSessMaxAge = UnixWeek * 2
|
||||
// DefaultSessionMaxAge is the default session expiration time in seconds.
|
||||
const DefaultSessionMaxAge = UnixWeek * 2
|
||||
|
||||
// DefaultSessTimeout is the default session timeout time in seconds.
|
||||
const DefaultSessTimeout = UnixWeek
|
||||
// DefaultSessionTimeout is the default session timeout time in seconds.
|
||||
const DefaultSessionTimeout = UnixWeek
|
||||
|
|
|
@ -31,13 +31,13 @@ func TestConfig_TLSEmail(t *testing.T) {
|
|||
func TestConfig_TLSCert(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
|
||||
assert.Equal(t, "/etc/ssl/certs/photoprism.me.crt", c.TLSCert())
|
||||
assert.True(t, strings.HasSuffix(c.TLSCert(), "photoprism.me.crt"))
|
||||
}
|
||||
|
||||
func TestConfig_TLSKey(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
|
||||
assert.Equal(t, "/etc/ssl/private/photoprism.me.key", c.TLSKey())
|
||||
assert.True(t, strings.HasSuffix(c.TLSKey(), "photoprism.me.key"))
|
||||
}
|
||||
|
||||
func TestConfig_TLS(t *testing.T) {
|
||||
|
|
|
@ -37,16 +37,16 @@ var Flags = CliFlags{
|
|||
EnvVar: "PHOTOPRISM_ADMIN_PASSWORD",
|
||||
}}, {
|
||||
Flag: cli.Int64Flag{
|
||||
Name: "sess-maxage",
|
||||
Value: DefaultSessMaxAge,
|
||||
Usage: "time in `SECONDS` until user sessions expire automatically (-1 to disable)",
|
||||
EnvVar: "PHOTOPRISM_SESS_MAXAGE",
|
||||
Name: "session-maxage",
|
||||
Value: DefaultSessionMaxAge,
|
||||
Usage: "time in `SECONDS` until API sessions expire automatically (-1 to disable)",
|
||||
EnvVar: "PHOTOPRISM_SESSION_MAXAGE",
|
||||
}}, {
|
||||
Flag: cli.Int64Flag{
|
||||
Name: "sess-timeout",
|
||||
Value: DefaultSessTimeout,
|
||||
Usage: "time in `SECONDS` until user sessions expire due to inactivity (-1 to disable)",
|
||||
EnvVar: "PHOTOPRISM_SESS_TIMEOUT",
|
||||
Name: "session-timeout",
|
||||
Value: DefaultSessionTimeout,
|
||||
Usage: "time in `SECONDS` until API sessions expire due to inactivity (-1 to disable)",
|
||||
EnvVar: "PHOTOPRISM_SESSION_TIMEOUT",
|
||||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
Name: "log-level, l",
|
||||
|
@ -209,11 +209,6 @@ var Flags = CliFlags{
|
|||
Usage: "enable experimental features",
|
||||
EnvVar: "PHOTOPRISM_EXPERIMENTAL",
|
||||
}}, {
|
||||
Flag: cli.BoolFlag{
|
||||
Name: "disable-tls",
|
||||
Usage: "disable HTTPS even if a certificate is available",
|
||||
EnvVar: "PHOTOPRISM_DISABLE_TLS",
|
||||
}}, {
|
||||
Flag: cli.BoolFlag{
|
||||
Name: "disable-webdav",
|
||||
Usage: "disable built-in WebDAV server",
|
||||
|
@ -451,6 +446,11 @@ var Flags = CliFlags{
|
|||
Usage: "Web server port `NUMBER`",
|
||||
EnvVar: "PHOTOPRISM_HTTP_PORT",
|
||||
}}, {
|
||||
Flag: cli.BoolFlag{
|
||||
Name: "disable-tls",
|
||||
Usage: "disable HTTPS even if a certificate is available",
|
||||
EnvVar: "PHOTOPRISM_DISABLE_TLS",
|
||||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
Name: "database-driver, db",
|
||||
Usage: "database `DRIVER` (sqlite, mysql)",
|
||||
|
@ -575,12 +575,12 @@ var Flags = CliFlags{
|
|||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
Name: "download-token",
|
||||
Usage: "`SECRET` download URL token for originals (default: random)",
|
||||
Usage: "`DEFAULT` download URL token for originals (leave empty for a random value)",
|
||||
EnvVar: "PHOTOPRISM_DOWNLOAD_TOKEN",
|
||||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
Name: "preview-token",
|
||||
Usage: "`SECRET` thumbnail and video streaming URL token (default: random)",
|
||||
Usage: "`DEFAULT` thumbnail and video streaming URL token (leave empty for a random value)",
|
||||
EnvVar: "PHOTOPRISM_PREVIEW_TOKEN",
|
||||
}}, {
|
||||
Flag: cli.StringFlag{
|
||||
|
|
|
@ -26,8 +26,8 @@ type Options struct {
|
|||
Public bool `yaml:"Public" json:"-" flag:"public"`
|
||||
AdminUser string `yaml:"AdminUser" json:"-" flag:"admin-user"`
|
||||
AdminPassword string `yaml:"AdminPassword" json:"-" flag:"admin-password"`
|
||||
SessMaxAge int64 `yaml:"SessMaxAge" json:"-" flag:"sess-maxage"`
|
||||
SessTimeout int64 `yaml:"SessTimeout" json:"-" flag:"sess-timeout"`
|
||||
SessionMaxAge int64 `yaml:"SessionMaxAge" json:"-" flag:"session-maxage"`
|
||||
SessionTimeout int64 `yaml:"SessionTimeout" json:"-" flag:"session-timeout"`
|
||||
LogLevel string `yaml:"LogLevel" json:"-" flag:"log-level"`
|
||||
Prod bool `yaml:"Prod" json:"Prod" flag:"prod"`
|
||||
Debug bool `yaml:"Debug" json:"Debug" flag:"debug"`
|
||||
|
@ -97,10 +97,10 @@ type Options struct {
|
|||
HttpCompression string `yaml:"HttpCompression" json:"-" flag:"http-compression"`
|
||||
HttpHost string `yaml:"HttpHost" json:"-" flag:"http-host"`
|
||||
HttpPort int `yaml:"HttpPort" json:"-" flag:"http-port"`
|
||||
DisableTLS bool `yaml:"DisableTLS" json:"DisableTLS" flag:"disable-tls"`
|
||||
TLSEmail string `yaml:"TLSEmail" json:"TLSEmail" flag:"tls-email"` // TLSEmail enabled automatic HTTPS via Let's Encrypt if set a valid email address.
|
||||
TLSCert string `yaml:"TLSCert" json:"TLSCert" flag:"tls-cert"`
|
||||
TLSKey string `yaml:"TLSKey" json:"TLSKey" flag:"tls-key"`
|
||||
DisableTLS bool `yaml:"DisableTLS" json:"DisableTLS" flag:"disable-tls"`
|
||||
DatabaseDriver string `yaml:"DatabaseDriver" json:"-" flag:"database-driver"`
|
||||
DatabaseDsn string `yaml:"DatabaseDsn" json:"-" flag:"database-dsn"`
|
||||
DatabaseName string `yaml:"DatabaseName" json:"-" flag:"database-name"`
|
||||
|
|
|
@ -25,8 +25,8 @@ func (c *Config) Report() (rows [][]string, cols []string) {
|
|||
{"admin-user", c.AdminUser()},
|
||||
{"admin-password", strings.Repeat("*", utf8.RuneCountInString(c.AdminPassword()))},
|
||||
{"public", fmt.Sprintf("%t", c.Public())},
|
||||
{"sess-maxage", fmt.Sprintf("%d", c.SessMaxAge())},
|
||||
{"sess-timeout", fmt.Sprintf("%d", c.SessTimeout())},
|
||||
{"session-maxage", fmt.Sprintf("%d", c.SessionMaxAge())},
|
||||
{"session-timeout", fmt.Sprintf("%d", c.SessionTimeout())},
|
||||
|
||||
// Logging.
|
||||
{"log-level", c.LogLevel().String()},
|
||||
|
@ -72,7 +72,6 @@ func (c *Config) Report() (rows [][]string, cols []string) {
|
|||
// Feature Flags.
|
||||
{"read-only", fmt.Sprintf("%t", c.ReadOnly())},
|
||||
{"experimental", fmt.Sprintf("%t", c.Experimental())},
|
||||
{"disable-tls", fmt.Sprintf("%t", c.DisableTLS())},
|
||||
{"disable-webdav", fmt.Sprintf("%t", c.DisableWebDAV())},
|
||||
{"disable-settings", fmt.Sprintf("%t", c.DisableSettings())},
|
||||
{"disable-places", fmt.Sprintf("%t", c.DisablePlaces())},
|
||||
|
@ -137,6 +136,7 @@ func (c *Config) Report() (rows [][]string, cols []string) {
|
|||
{"http-compression", c.HttpCompression()},
|
||||
{"http-host", c.HttpHost()},
|
||||
{"http-port", fmt.Sprintf("%d", c.HttpPort())},
|
||||
{"disable-tls", fmt.Sprintf("%t", c.DisableTLS())},
|
||||
{"tls-email", c.TLSEmail()},
|
||||
{"tls-cert", c.TLSCert()},
|
||||
{"tls-key", c.TLSKey()},
|
||||
|
|
|
@ -73,7 +73,7 @@ func RawExif(fileName string, fileFormat fs.Type, bruteForce bool) (rawExif []by
|
|||
parsed = true
|
||||
}
|
||||
}
|
||||
case fs.ImageHEIF:
|
||||
case fs.ImageHEIC:
|
||||
heicMp := heicexif.NewHeicExifMediaParser()
|
||||
|
||||
cs, err := heicMp.ParseFile(fileName)
|
||||
|
|
|
@ -172,7 +172,7 @@ func TestExif(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("iphone_7.heic", func(t *testing.T) {
|
||||
data, err := Exif("testdata/iphone_7.heic", fs.ImageHEIF, true)
|
||||
data, err := Exif("testdata/iphone_7.heic", fs.ImageHEIC, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -794,7 +794,7 @@ func (m *MediaFile) FileType() fs.Type {
|
|||
case m.IsAVIF():
|
||||
return fs.ImageAVIF
|
||||
case m.IsHEIC():
|
||||
return fs.ImageHEIF
|
||||
return fs.ImageHEIC
|
||||
default:
|
||||
return fs.FileType(m.fileName)
|
||||
}
|
||||
|
@ -871,7 +871,7 @@ func (m *MediaFile) IsLive() bool {
|
|||
}
|
||||
|
||||
if m.IsVideo() {
|
||||
return fs.ImageHEIF.FindFirst(m.FileName(), []string{}, Config().OriginalsPath(), false) != ""
|
||||
return fs.ImageHEIC.FindFirst(m.FileName(), []string{}, Config().OriginalsPath(), false) != ""
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
|
@ -317,7 +317,7 @@ func TestMediaFile_Exif_DNG(t *testing.T) {
|
|||
assert.NotEmpty(t, info.Height)
|
||||
}
|
||||
|
||||
func TestMediaFile_Exif_HEIF(t *testing.T) {
|
||||
func TestMediaFile_Exif_HEIC(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
|
|
|
@ -1113,7 +1113,7 @@ func TestMediaFile_HasType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, true, mediaFile.HasFileType("heif"))
|
||||
assert.Equal(t, true, mediaFile.HasFileType("heic"))
|
||||
})
|
||||
t.Run("iphone_7.xmp", func(t *testing.T) {
|
||||
mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/iphone_7.xmp")
|
||||
|
@ -1124,7 +1124,7 @@ func TestMediaFile_HasType(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestMediaFile_IsHEIF(t *testing.T) {
|
||||
func TestMediaFile_IsHEIC(t *testing.T) {
|
||||
conf := config.TestConfig()
|
||||
|
||||
t.Run("iphone_7.json", func(t *testing.T) {
|
||||
|
|
|
@ -175,7 +175,7 @@ func TestRelatedFiles_MainFileType(t *testing.T) {
|
|||
Files: MediaFiles{mediaFile, mediaFile2},
|
||||
Main: mediaFile3,
|
||||
}
|
||||
assert.Equal(t, string(fs.ImageHEIF), relatedFiles.MainFileType())
|
||||
assert.Equal(t, string(fs.ImageHEIC), relatedFiles.MainFileType())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func ShareSelection(originals bool) FileSelection {
|
|||
fs.ImageWebP.String(),
|
||||
fs.ImageTIFF.String(),
|
||||
fs.ImageAVIF.String(),
|
||||
fs.ImageHEIF.String(),
|
||||
fs.ImageHEIC.String(),
|
||||
fs.ImageBMP.String(),
|
||||
fs.ImageGIF.String(),
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ import (
|
|||
|
||||
// New creates a session with a context if it is specified.
|
||||
func (s *Session) New(c *gin.Context) (m *entity.Session) {
|
||||
return entity.NewSession(s.conf.SessMaxAge(), s.conf.SessTimeout()).SetContext(c)
|
||||
return entity.NewSession(s.conf.SessionMaxAge(), s.conf.SessionTimeout()).SetContext(c)
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ var Extensions = FileExtensions{
|
|||
".dng": ImageDNG,
|
||||
".avif": ImageAVIF,
|
||||
".avifs": ImageAVIF,
|
||||
".heif": ImageHEIF,
|
||||
".hif": ImageHEIF,
|
||||
".heic": ImageHEIF,
|
||||
".heifs": ImageHEIF,
|
||||
".heics": ImageHEIF,
|
||||
".avci": ImageHEIF,
|
||||
".avcs": ImageHEIF,
|
||||
".heif": ImageHEIC,
|
||||
".hif": ImageHEIC,
|
||||
".heic": ImageHEIC,
|
||||
".heifs": ImageHEIC,
|
||||
".heics": ImageHEIC,
|
||||
".avci": ImageHEIC,
|
||||
".avcs": ImageHEIC,
|
||||
".webp": ImageWebP,
|
||||
".mpo": ImageMPO,
|
||||
".3fr": ImageRaw,
|
||||
|
|
|
@ -19,7 +19,8 @@ const (
|
|||
ImageTIFF Type = "tiff" // TIFF image
|
||||
ImageDNG Type = "dng" // Adobe Digital Negative image
|
||||
ImageAVIF Type = "avif" // AV1 Image File Format (AVIF)
|
||||
ImageHEIF Type = "heif" // High Efficiency Image File Format (HEIF/HEIC)
|
||||
ImageHEIF Type = "heif" // High Efficiency Image File Format (HEIF)
|
||||
ImageHEIC Type = "heic" // High Efficiency Image Container (HEIC)
|
||||
ImageBMP Type = "bmp" // BMP image
|
||||
ImageMPO Type = "mpo" // Stereoscopic Image that consists of two JPG images that are combined into one 3D image
|
||||
ImageWebP Type = "webp" // Google WebP Image
|
||||
|
|
|
@ -12,6 +12,7 @@ var TypeInfo = map[Type]string{
|
|||
ImageMPO: "Stereoscopic JPEG (3D)",
|
||||
ImageAVIF: "AV1 Image File Format",
|
||||
ImageHEIF: "High Efficiency Image File Format",
|
||||
ImageHEIC: "High Efficiency Image Container",
|
||||
ImageWebP: "Google WebP",
|
||||
VideoWebM: "Google WebM",
|
||||
VideoMP2: "MPEG 2 (H.262)",
|
||||
|
|
|
@ -13,7 +13,7 @@ var Formats = map[fs.Type]Type{
|
|||
fs.ImageBMP: Image,
|
||||
fs.ImageMPO: Image,
|
||||
fs.ImageAVIF: Image,
|
||||
fs.ImageHEIF: Image,
|
||||
fs.ImageHEIC: Image,
|
||||
fs.VideoHEVC: Video,
|
||||
fs.ImageWebP: Image,
|
||||
fs.VideoWebM: Video,
|
||||
|
|
Loading…
Reference in a new issue