mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
fix default config persistence
This commit is contained in:
@@ -25,7 +25,7 @@ type BTSets struct {
|
|||||||
ForceEncrypt bool
|
ForceEncrypt bool
|
||||||
RetrackersMode int // 0 - don`t add, 1 - add retrackers (def), 2 - remove retrackers 3 - replace retrackers
|
RetrackersMode int // 0 - don`t add, 1 - add retrackers (def), 2 - remove retrackers 3 - replace retrackers
|
||||||
TorrentDisconnectTimeout int // in seconds
|
TorrentDisconnectTimeout int // in seconds
|
||||||
EnableDebug bool // print logs
|
EnableDebug bool // debug logs
|
||||||
|
|
||||||
// DLNA
|
// DLNA
|
||||||
EnableDLNA bool
|
EnableDLNA bool
|
||||||
@@ -59,7 +59,7 @@ func SetBTSets(sets *BTSets) {
|
|||||||
if ReadOnly {
|
if ReadOnly {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// failsafe (load defaults)
|
// failsafe checks (use defaults)
|
||||||
if sets.CacheSize == 0 {
|
if sets.CacheSize == 0 {
|
||||||
sets.CacheSize = 64 * 1024 * 1024
|
sets.CacheSize = 64 * 1024 * 1024
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,25 @@ func SetBTSets(sets *BTSets) {
|
|||||||
tdb.Set("Settings", "BitTorr", buf)
|
tdb.Set("Settings", "BitTorr", buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetDefaultConfig() {
|
||||||
|
sets := new(BTSets)
|
||||||
|
sets.CacheSize = 64 * 1024 * 1024 // 64 MB
|
||||||
|
sets.PreloadCache = 50
|
||||||
|
sets.ConnectionsLimit = 25
|
||||||
|
sets.RetrackersMode = 1
|
||||||
|
sets.TorrentDisconnectTimeout = 30
|
||||||
|
sets.ReaderReadAHead = 95 // 95%
|
||||||
|
BTsets = sets
|
||||||
|
if !ReadOnly {
|
||||||
|
buf, err := json.Marshal(BTsets)
|
||||||
|
if err != nil {
|
||||||
|
log.TLogln("Error marshal btsets", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tdb.Set("Settings", "BitTorr", buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func loadBTSets() {
|
func loadBTSets() {
|
||||||
buf := tdb.Get("Settings", "BitTorr")
|
buf := tdb.Get("Settings", "BitTorr")
|
||||||
if len(buf) > 0 {
|
if len(buf) > 0 {
|
||||||
@@ -127,17 +146,5 @@ func loadBTSets() {
|
|||||||
log.TLogln("Error unmarshal btsets", err)
|
log.TLogln("Error unmarshal btsets", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDefault()
|
SetDefaultConfig()
|
||||||
}
|
|
||||||
|
|
||||||
func SetDefault() {
|
|
||||||
sets := new(BTSets)
|
|
||||||
sets.EnableDebug = false
|
|
||||||
sets.CacheSize = 64 * 1024 * 1024 // 64 MB
|
|
||||||
sets.PreloadCache = 50
|
|
||||||
sets.ConnectionsLimit = 25
|
|
||||||
sets.RetrackersMode = 1
|
|
||||||
sets.TorrentDisconnectTimeout = 30
|
|
||||||
sets.ReaderReadAHead = 95 // 95%
|
|
||||||
BTsets = sets
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ func SetDefSettings() {
|
|||||||
if sets.ReadOnly {
|
if sets.ReadOnly {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sets.SetDefault()
|
sets.SetDefaultConfig()
|
||||||
log.TLogln("drop all torrents")
|
log.TLogln("drop all torrents")
|
||||||
dropAllTorrent()
|
dropAllTorrent()
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user