Files
core/config/dummy.go
2022-07-22 08:33:38 +02:00

84 lines
1.3 KiB
Go

package config
import "fmt"
type dummyStore struct {
current *Config
active *Config
}
// NewDummyStore returns a store that returns the default config
func NewDummyStore() Store {
s := &dummyStore{}
cfg := New()
cfg.DB.Dir = "."
cfg.FFmpeg.Binary = "true"
cfg.Storage.Disk.Dir = "."
cfg.Storage.MimeTypes = ""
s.current = cfg
cfg = New()
cfg.DB.Dir = "."
cfg.FFmpeg.Binary = "true"
cfg.Storage.Disk.Dir = "."
cfg.Storage.MimeTypes = ""
s.active = cfg
return s
}
func (c *dummyStore) Get() *Config {
cfg := New()
cfg.DB.Dir = "."
cfg.FFmpeg.Binary = "true"
cfg.Storage.Disk.Dir = "."
cfg.Storage.MimeTypes = ""
return cfg
}
func (c *dummyStore) Set(d *Config) error {
d.Validate(true)
if d.HasErrors() {
return fmt.Errorf("configuration data has errors after validation")
}
c.current = NewConfigFrom(d)
return nil
}
func (c *dummyStore) GetActive() *Config {
cfg := New()
cfg.DB.Dir = "."
cfg.FFmpeg.Binary = "true"
cfg.Storage.Disk.Dir = "."
cfg.Storage.MimeTypes = ""
return cfg
}
func (c *dummyStore) SetActive(d *Config) error {
d.Validate(true)
if d.HasErrors() {
return fmt.Errorf("configuration data has errors after validation")
}
c.active = NewConfigFrom(d)
return nil
}
func (c *dummyStore) Reload() error {
return nil
}