mirror of https://github.com/synctv-org/synctv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
610 B
Go
38 lines
610 B
Go
package op
|
|
|
|
import (
|
|
"github.com/bluele/gcache"
|
|
"github.com/synctv-org/synctv/internal/db"
|
|
"github.com/synctv-org/synctv/internal/model"
|
|
)
|
|
|
|
func Init(size int) error {
|
|
userCache = gcache.New(size).
|
|
LRU().
|
|
Build()
|
|
|
|
err := initSettings(ToSettings(BoolSettings)...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func initSettings(i ...Setting) error {
|
|
for _, b := range i {
|
|
s := &model.Setting{
|
|
Name: b.Name(),
|
|
Value: b.Raw(),
|
|
Type: b.Type(),
|
|
Group: b.Group(),
|
|
}
|
|
err := db.FirstOrCreateSettingItemValue(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.InitRaw(s.Value)
|
|
}
|
|
return nil
|
|
}
|