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)
|
log.TLogln("Error unmarshal btsets", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetDefault() {
|
||||||
sets := new(BTSets)
|
sets := new(BTSets)
|
||||||
sets.EnableDebug = false
|
sets.EnableDebug = false
|
||||||
sets.DisableUTP = true
|
sets.DisableUTP = true
|
||||||
|
|||||||
@@ -129,6 +129,15 @@ func SetSettings(set *sets.BTSets) {
|
|||||||
bts.Connect()
|
bts.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetDefSettings() {
|
||||||
|
if sets.ReadOnly {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bts.Disconnect()
|
||||||
|
sets.SetDefault()
|
||||||
|
bts.Connect()
|
||||||
|
}
|
||||||
|
|
||||||
func Shutdown() {
|
func Shutdown() {
|
||||||
bts.Disconnect()
|
bts.Disconnect()
|
||||||
sets.CloseDB()
|
sets.CloseDB()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"server/torr"
|
"server/torr"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Action: get, set
|
//Action: get, set, def
|
||||||
type setsReqJS struct {
|
type setsReqJS struct {
|
||||||
requestI
|
requestI
|
||||||
Sets *sets.BTSets `json:"sets,omitempty"`
|
Sets *sets.BTSets `json:"sets,omitempty"`
|
||||||
@@ -27,11 +27,14 @@ func settings(c *gin.Context) {
|
|||||||
if req.Action == "get" {
|
if req.Action == "get" {
|
||||||
c.JSON(200, sets.BTsets)
|
c.JSON(200, sets.BTsets)
|
||||||
return
|
return
|
||||||
}
|
} else if req.Action == "set" {
|
||||||
if req.Action == "set" {
|
|
||||||
torr.SetSettings(req.Sets)
|
torr.SetSettings(req.Sets)
|
||||||
c.Status(200)
|
c.Status(200)
|
||||||
return
|
return
|
||||||
|
} else if req.Action == "def" {
|
||||||
|
torr.SetDefSettings()
|
||||||
|
c.Status(200)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
c.AbortWithError(http.StatusBadRequest, errors.New("action is empty"))
|
c.AbortWithError(http.StatusBadRequest, errors.New("action is empty"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user