mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
revert to _9 and add save info bytes
This commit is contained in:
@@ -31,19 +31,18 @@ type Settings struct {
|
||||
RetrackersMode int //0 - don`t add, 1 - add retrackers, 2 - remove retrackers
|
||||
|
||||
//BT Config
|
||||
EnableIPv6 bool
|
||||
DisableTCP bool
|
||||
DisableUTP bool
|
||||
DisableUPNP bool
|
||||
DisableDHT bool
|
||||
DisableUpload bool
|
||||
//Encryption int // 0 - Enable, 1 - disable, 2 - force
|
||||
EnableIPv6 bool
|
||||
DisableTCP bool
|
||||
DisableUTP bool
|
||||
DisableUPNP bool
|
||||
DisableDHT bool
|
||||
DisableUpload bool
|
||||
Encryption int // 0 - Enable, 1 - disable, 2 - force
|
||||
DownloadRateLimit int // in kb, 0 - inf
|
||||
UploadRateLimit int // in kb, 0 - inf
|
||||
ConnectionsLimit int
|
||||
DhtConnectionLimit int // 0 - inf
|
||||
PeersListenPort int
|
||||
PeerStrategy int // 0 - Timeout, 1 - Fastest, 2 - Fuzzing
|
||||
|
||||
TorrentDisconnectTimeout int // in seconds
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
type Torrent struct {
|
||||
Name string
|
||||
Magnet string
|
||||
InfoBytes []byte
|
||||
Hash string
|
||||
Size int64
|
||||
Timestamp int64
|
||||
@@ -83,6 +84,10 @@ func SaveTorrentDB(torrent *Torrent) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("error save torrent: %v", err)
|
||||
}
|
||||
err = hdb.Put([]byte("InfoBytes"), torrent.InfoBytes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error save torrent: %v", err)
|
||||
}
|
||||
err = hdb.Put([]byte("Size"), i2b(torrent.Size))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error save torrent: %v", err)
|
||||
@@ -172,6 +177,13 @@ func LoadTorrentDB(hash string) (*Torrent, error) {
|
||||
}
|
||||
torr.Magnet = string(tmp)
|
||||
|
||||
tmp = hdb.Get([]byte("InfoBytes"))
|
||||
if len(tmp) > 0 {
|
||||
torr.InfoBytes = tmp
|
||||
} else {
|
||||
torr.InfoBytes = nil
|
||||
}
|
||||
|
||||
tmp = hdb.Get([]byte("Size"))
|
||||
if tmp == nil {
|
||||
return fmt.Errorf("error load torrent")
|
||||
|
||||
Reference in New Issue
Block a user