mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
* Added flags to customize the host and port * Start up just one server rather than a server for HTTP and HTTPS. HTTPS server will only start if a cert and key are found
59 lines
1002 B
Go
59 lines
1002 B
Go
package config
|
|
|
|
import (
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
const Stash = "stash"
|
|
const Cache = "cache"
|
|
const Generated = "generated"
|
|
const Metadata = "metadata"
|
|
const Downloads = "downloads"
|
|
|
|
const Database = "database"
|
|
|
|
const Host = "host"
|
|
const Port = "port"
|
|
|
|
func Set(key string, value interface{}) {
|
|
viper.Set(key, value)
|
|
}
|
|
|
|
func Write() error {
|
|
return viper.WriteConfig()
|
|
}
|
|
|
|
func GetStashPaths() []string {
|
|
return viper.GetStringSlice(Stash)
|
|
}
|
|
|
|
func GetCachePath() string {
|
|
return viper.GetString(Cache)
|
|
}
|
|
|
|
func GetGeneratedPath() string {
|
|
return viper.GetString(Generated)
|
|
}
|
|
|
|
func GetMetadataPath() string {
|
|
return viper.GetString(Metadata)
|
|
}
|
|
|
|
func GetDatabasePath() string {
|
|
return viper.GetString(Database)
|
|
}
|
|
|
|
func GetHost() string {
|
|
return viper.GetString(Host)
|
|
}
|
|
|
|
func GetPort() int {
|
|
return viper.GetInt(Port)
|
|
}
|
|
|
|
func IsValid() bool {
|
|
setPaths := viper.IsSet(Stash) && viper.IsSet(Cache) && viper.IsSet(Generated) && viper.IsSet(Metadata)
|
|
// TODO: check valid paths
|
|
return setPaths
|
|
}
|