mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
fix data override on torrent edit via web
This commit is contained in:
@@ -136,14 +136,18 @@ func SetTorrent(hashHex, title, poster, category string, data string) *Torrent {
|
|||||||
torr.Title = title
|
torr.Title = title
|
||||||
torr.Poster = poster
|
torr.Poster = poster
|
||||||
torr.Category = category
|
torr.Category = category
|
||||||
torr.Data = data
|
if data != "" {
|
||||||
|
torr.Data = data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if torrDb != nil {
|
if torrDb != nil {
|
||||||
torrDb.Title = title
|
torrDb.Title = title
|
||||||
torrDb.Poster = poster
|
torrDb.Poster = poster
|
||||||
torrDb.Category = category
|
torrDb.Category = category
|
||||||
torrDb.Data = data
|
if data != "" {
|
||||||
|
torrDb.Data = data
|
||||||
|
}
|
||||||
AddTorrentDB(torrDb)
|
AddTorrentDB(torrDb)
|
||||||
}
|
}
|
||||||
if torr != nil {
|
if torr != nil {
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"server/torr/utils"
|
|
||||||
|
|
||||||
"server/settings"
|
"server/settings"
|
||||||
"server/torr/state"
|
"server/torr/state"
|
||||||
|
"server/torr/utils"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
)
|
)
|
||||||
@@ -26,9 +25,11 @@ func AddTorrentDB(torr *Torrent) {
|
|||||||
if torr.Data == "" {
|
if torr.Data == "" {
|
||||||
files := new(tsFiles)
|
files := new(tsFiles)
|
||||||
files.TorrServer.Files = torr.Status().FileStats
|
files.TorrServer.Files = torr.Status().FileStats
|
||||||
buf, _ := json.Marshal(files)
|
buf, err := json.Marshal(files)
|
||||||
t.Data = string(buf)
|
if err == nil {
|
||||||
torr.Data = t.Data
|
t.Data = string(buf)
|
||||||
|
torr.Data = t.Data
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
t.Data = torr.Data
|
t.Data = torr.Data
|
||||||
}
|
}
|
||||||
@@ -51,11 +52,11 @@ func GetTorrentDB(hash metainfo.Hash) *Torrent {
|
|||||||
torr.TorrentSpec = db.TorrentSpec
|
torr.TorrentSpec = db.TorrentSpec
|
||||||
torr.Title = db.Title
|
torr.Title = db.Title
|
||||||
torr.Poster = db.Poster
|
torr.Poster = db.Poster
|
||||||
|
torr.Category = db.Category
|
||||||
torr.Timestamp = db.Timestamp
|
torr.Timestamp = db.Timestamp
|
||||||
torr.Size = db.Size
|
torr.Size = db.Size
|
||||||
torr.Data = db.Data
|
torr.Data = db.Data
|
||||||
torr.Stat = state.TorrentInDB
|
torr.Stat = state.TorrentInDB
|
||||||
torr.Category = db.Category
|
|
||||||
return torr
|
return torr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,9 +75,9 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent {
|
|||||||
torr.TorrentSpec = db.TorrentSpec
|
torr.TorrentSpec = db.TorrentSpec
|
||||||
torr.Title = db.Title
|
torr.Title = db.Title
|
||||||
torr.Poster = db.Poster
|
torr.Poster = db.Poster
|
||||||
|
torr.Category = db.Category
|
||||||
torr.Timestamp = db.Timestamp
|
torr.Timestamp = db.Timestamp
|
||||||
torr.Size = db.Size
|
torr.Size = db.Size
|
||||||
torr.Category = db.Category
|
|
||||||
torr.Data = db.Data
|
torr.Data = db.Data
|
||||||
torr.Stat = state.TorrentInDB
|
torr.Stat = state.TorrentInDB
|
||||||
ret[torr.TorrentSpec.InfoHash] = torr
|
ret[torr.TorrentSpec.InfoHash] = torr
|
||||||
|
|||||||
@@ -97,7 +97,12 @@ func addTorrent(req torrReqJS, c *gin.Context) {
|
|||||||
|
|
||||||
tor, err := torr.AddTorrent(torrSpec, req.Title, req.Poster, req.Data, req.Category)
|
tor, err := torr.AddTorrent(torrSpec, req.Title, req.Poster, req.Data, req.Category)
|
||||||
|
|
||||||
log.TLogln("Final torrent category:", tor.Category)
|
if tor.Data != "" {
|
||||||
|
log.TLogln("torrent data:", tor.Data)
|
||||||
|
}
|
||||||
|
if tor.Category != "" {
|
||||||
|
log.TLogln("torrent category:", tor.Category)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("error add torrent:", err)
|
log.TLogln("error add torrent:", err)
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ func torrentUpload(c *gin.Context) {
|
|||||||
|
|
||||||
tor, err = torr.AddTorrent(spec, title, poster, data, category)
|
tor, err = torr.AddTorrent(spec, title, poster, data, category)
|
||||||
|
|
||||||
log.TLogln("Final torrent category:", tor.Category)
|
if tor.Data != "" {
|
||||||
|
log.TLogln("torrent data:", tor.Data)
|
||||||
|
}
|
||||||
|
if tor.Category != "" {
|
||||||
|
log.TLogln("torrent category:", tor.Category)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("error upload torrent:", err)
|
log.TLogln("error upload torrent:", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user