mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
move Settings and Viewed to separate json files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -8,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
tdb *TDB
|
||||
tdb TorrServerDB
|
||||
Path string
|
||||
Port string
|
||||
Ssl bool
|
||||
@@ -24,13 +25,35 @@ var (
|
||||
func InitSets(readOnly, searchWA bool) {
|
||||
ReadOnly = readOnly
|
||||
SearchWA = searchWA
|
||||
tdb = NewTDB()
|
||||
if tdb == nil {
|
||||
log.TLogln("Error open db:", filepath.Join(Path, "config.db"))
|
||||
|
||||
bboltDB := NewTDB()
|
||||
if bboltDB == nil {
|
||||
log.TLogln("Error open bboltDB:", filepath.Join(Path, "config.db"))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
jsonDB := NewJsonDB()
|
||||
if jsonDB == nil {
|
||||
log.TLogln("Error open jsonDB")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
dbRouter := NewXPathDBRouter()
|
||||
// First registered DB becomes default route
|
||||
dbRouter.RegisterRoute(jsonDB, "Settings")
|
||||
dbRouter.RegisterRoute(jsonDB, "Viewed")
|
||||
dbRouter.RegisterRoute(bboltDB, "Torrents")
|
||||
|
||||
tdb = NewDBReadCache(dbRouter)
|
||||
|
||||
// We migrate settings here, it must be done before loadBTSets()
|
||||
if err := Migrate2(bboltDB, jsonDB); err != nil {
|
||||
log.TLogln(fmt.Sprintf("Migrate2 failed"))
|
||||
os.Exit(1)
|
||||
}
|
||||
loadBTSets()
|
||||
Migrate()
|
||||
Migrate1()
|
||||
|
||||
}
|
||||
|
||||
func CloseDB() {
|
||||
|
||||
Reference in New Issue
Block a user