mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-01-23 02:35:10 +00:00
feat: make server options a struct (#615)
Former-commit-id: a54bc7c8a0fb700d4f90f78c54d6cb028e8acea7 [formerly a0946a1d5b82ce5681684bc0f871bd892c4d6c3f] [formerly 6b23b0abbe5cde6a6348f982975d15a1161359de [formerly 0e7abaa7fb]]
Former-commit-id: cf9ea1110bcb8b5eb30ecd25db1928659ecea922 [formerly 38cebeff1f9e6b03760f7b277a3941f7bd733fb5]
Former-commit-id: db44c1d5ff8fed361849b5bf1fe48e04c75d7ce7
This commit is contained in:
parent
802318f903
commit
01929c72ea
13 changed files with 159 additions and 90 deletions
|
|
@ -17,3 +17,12 @@ func (s settingsBackend) Get() (*settings.Settings, error) {
|
|||
func (s settingsBackend) Save(settings *settings.Settings) error {
|
||||
return save(s.db, "settings", settings)
|
||||
}
|
||||
|
||||
func (s settingsBackend) GetServer() (*settings.Server, error) {
|
||||
server := &settings.Server{}
|
||||
return server, get(s.db, "server", server)
|
||||
}
|
||||
|
||||
func (s settingsBackend) SaveServer(server *settings.Server) error {
|
||||
return save(s.db, "server", server)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ type oldAuth struct {
|
|||
}
|
||||
|
||||
type oldConf struct {
|
||||
Port int `json:"port" yaml:"port" toml:"port"`
|
||||
Port string `json:"port" yaml:"port" toml:"port"`
|
||||
BaseURL string `json:"baseURL" yaml:"baseURL" toml:"baseURL"`
|
||||
Log string `json:"log" yaml:"log" toml:"log"`
|
||||
Address string `json:"address" yaml:"address" toml:"address"`
|
||||
|
|
@ -47,7 +47,7 @@ type oldConf struct {
|
|||
}
|
||||
|
||||
var defaults = &oldConf{
|
||||
Port: 0,
|
||||
Port: "0",
|
||||
Log: "stdout",
|
||||
Defaults: oldDefs{
|
||||
Commands: []string{"git", "svn", "hg"},
|
||||
|
|
@ -110,7 +110,6 @@ func importConf(db *storm.DB, path string, sto *storage.Storage) error {
|
|||
|
||||
s := &settings.Settings{
|
||||
Key: key,
|
||||
BaseURL: cfg.BaseURL,
|
||||
Signup: false,
|
||||
Defaults: settings.UserDefaults{
|
||||
Scope: cfg.Defaults.Scope,
|
||||
|
|
@ -130,6 +129,13 @@ func importConf(db *storm.DB, path string, sto *storage.Storage) error {
|
|||
},
|
||||
}
|
||||
|
||||
server := &settings.Server{
|
||||
BaseURL : cfg.BaseURL,
|
||||
Port : cfg.Port,
|
||||
Address : cfg.Address,
|
||||
Log : cfg.Log,
|
||||
}
|
||||
|
||||
var auther auth.Auther
|
||||
switch cfg.Auth.Method {
|
||||
case "proxy":
|
||||
|
|
@ -159,6 +165,11 @@ func importConf(db *storm.DB, path string, sto *storage.Storage) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = sto.Settings.SaveServer(server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Configuration successfully imported.")
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue