fix dblock on failure #964
This commit is contained in:
+7
-1
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
@@ -49,7 +50,12 @@ func OpenDB(dbPath string) error {
|
||||
c := &gorm.Config{
|
||||
Logger: gormLogger,
|
||||
}
|
||||
db, err = gorm.Open(sqlite.Open(dbPath), c)
|
||||
sep := "?"
|
||||
if strings.Contains(dbPath, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
dsn := dbPath + sep + "_busy_timeout=10000"
|
||||
db, err = gorm.Open(sqlite.Open(dsn), c)
|
||||
|
||||
if config.IsDebug() {
|
||||
db = db.Debug()
|
||||
|
||||
+3
-1
@@ -169,7 +169,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.restartCoreWithConfig(data)
|
||||
configData := make(json.RawMessage, len(data))
|
||||
copy(configData, data)
|
||||
go func() { _ = s.restartCoreWithConfig(configData) }()
|
||||
case "settings":
|
||||
err = s.SettingService.Save(tx, data)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user