mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add def settings
This commit is contained in:
@@ -76,6 +76,10 @@ func loadBTSets() {
|
||||
log.TLogln("Error unmarshal btsets", err)
|
||||
}
|
||||
|
||||
SetDefault()
|
||||
}
|
||||
|
||||
func SetDefault() {
|
||||
sets := new(BTSets)
|
||||
sets.EnableDebug = false
|
||||
sets.DisableUTP = true
|
||||
|
||||
@@ -129,6 +129,15 @@ func SetSettings(set *sets.BTSets) {
|
||||
bts.Connect()
|
||||
}
|
||||
|
||||
func SetDefSettings() {
|
||||
if sets.ReadOnly {
|
||||
return
|
||||
}
|
||||
bts.Disconnect()
|
||||
sets.SetDefault()
|
||||
bts.Connect()
|
||||
}
|
||||
|
||||
func Shutdown() {
|
||||
bts.Disconnect()
|
||||
sets.CloseDB()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"server/torr"
|
||||
)
|
||||
|
||||
//Action: get, set
|
||||
//Action: get, set, def
|
||||
type setsReqJS struct {
|
||||
requestI
|
||||
Sets *sets.BTSets `json:"sets,omitempty"`
|
||||
@@ -27,11 +27,14 @@ func settings(c *gin.Context) {
|
||||
if req.Action == "get" {
|
||||
c.JSON(200, sets.BTsets)
|
||||
return
|
||||
}
|
||||
if req.Action == "set" {
|
||||
} else if req.Action == "set" {
|
||||
torr.SetSettings(req.Sets)
|
||||
c.Status(200)
|
||||
return
|
||||
} else if req.Action == "def" {
|
||||
torr.SetDefSettings()
|
||||
c.Status(200)
|
||||
return
|
||||
}
|
||||
c.AbortWithError(http.StatusBadRequest, errors.New("action is empty"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user