mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 22:19:07 +00:00
Add environment variables to disable features
Face detection still needs to be hidden on the frontend if it's disabled
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// EnvironmentVariable represents the name of an environment variable used to configure Photoview
|
||||
type EnvironmentVariable string
|
||||
@@ -30,6 +33,13 @@ const (
|
||||
EnvSqlitePath EnvironmentVariable = "PHOTOVIEW_SQLITE_PATH"
|
||||
)
|
||||
|
||||
// Feature related
|
||||
const (
|
||||
EnvDisableFaceRecognition EnvironmentVariable = "PHOTOVIEW_DISABLE_FACE_RECOGNITION"
|
||||
EnvDisableVideoEncoding EnvironmentVariable = "PHOTOVIEW_DISABLE_VIDEO_ENCODING"
|
||||
EnvDisableRawProcessing EnvironmentVariable = "PHOTOVIEW_DISABLE_RAW_PROCESSING"
|
||||
)
|
||||
|
||||
// GetName returns the name of the environment variable itself
|
||||
func (v EnvironmentVariable) GetName() string {
|
||||
return string(v)
|
||||
@@ -40,6 +50,20 @@ func (v EnvironmentVariable) GetValue() string {
|
||||
return os.Getenv(string(v))
|
||||
}
|
||||
|
||||
// GetBool returns the environment variable as a boolean (defaults to false if not defined)
|
||||
func (v EnvironmentVariable) GetBool() bool {
|
||||
value := strings.ToLower(os.Getenv(string(v)))
|
||||
trueValues := []string{"1", "true"}
|
||||
|
||||
for _, x := range trueValues {
|
||||
if value == x {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// ShouldServeUI whether or not the "serve ui" option is enabled
|
||||
func ShouldServeUI() bool {
|
||||
return EnvServeUI.GetValue() == "1"
|
||||
|
||||
Reference in New Issue
Block a user