mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
set short timeouts in GetTorrent, NewTorrent and Preload log
This commit is contained in:
@@ -87,9 +87,13 @@ func SaveTorrentToDB(torr *Torrent) {
|
|||||||
|
|
||||||
func GetTorrent(hashHex string) *Torrent {
|
func GetTorrent(hashHex string) *Torrent {
|
||||||
hash := metainfo.NewHashFromHex(hashHex)
|
hash := metainfo.NewHashFromHex(hashHex)
|
||||||
|
timeout := time.Second * time.Duration(sets.BTsets.TorrentDisconnectTimeout)
|
||||||
|
if timeout > time.Minute {
|
||||||
|
timeout = time.Minute
|
||||||
|
}
|
||||||
tor := bts.GetTorrent(hash)
|
tor := bts.GetTorrent(hash)
|
||||||
if tor != nil {
|
if tor != nil {
|
||||||
tor.AddExpiredTime(time.Minute)
|
tor.AddExpiredTime(timeout)
|
||||||
return tor
|
return tor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,12 +59,16 @@ func (t *Torrent) Preload(index int, size int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.Info() != nil {
|
if t.Info() != nil {
|
||||||
|
timeout := time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout)
|
||||||
|
if timeout > time.Minute {
|
||||||
|
timeout = time.Minute
|
||||||
|
}
|
||||||
// Запуск лога в отдельном потоке
|
// Запуск лога в отдельном потоке
|
||||||
go func() {
|
go func() {
|
||||||
for t.Stat == state.TorrentPreload {
|
for t.Stat == state.TorrentPreload {
|
||||||
stat := fmt.Sprint(file.Torrent().InfoHash().HexString(), " ", utils2.Format(float64(t.PreloadedBytes)), "/", utils2.Format(float64(t.PreloadSize)), " Speed:", utils2.Format(t.DownloadSpeed), " Peers:", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers, " [Seeds:", t.Torrent.Stats().ConnectedSeeders, "]")
|
stat := fmt.Sprint(file.Torrent().InfoHash().HexString(), " ", utils2.Format(float64(t.PreloadedBytes)), "/", utils2.Format(float64(t.PreloadSize)), " Speed:", utils2.Format(t.DownloadSpeed), " Peers:", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers, " [Seeds:", t.Torrent.Stats().ConnectedSeeders, "]")
|
||||||
log.TLogln("Preload:", stat)
|
log.TLogln("Preload:", stat)
|
||||||
t.AddExpiredTime(time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout))
|
t.AddExpiredTime(timeout)
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
|
|||||||
return tor, nil
|
return tor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeout := time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout)
|
||||||
|
if timeout > time.Minute {
|
||||||
|
timeout = time.Minute
|
||||||
|
}
|
||||||
|
|
||||||
torr := new(Torrent)
|
torr := new(Torrent)
|
||||||
torr.Torrent = goTorrent
|
torr.Torrent = goTorrent
|
||||||
torr.Stat = state.TorrentAdded
|
torr.Stat = state.TorrentAdded
|
||||||
@@ -92,7 +97,7 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
|
|||||||
torr.bt = bt
|
torr.bt = bt
|
||||||
torr.closed = goTorrent.Closed()
|
torr.closed = goTorrent.Closed()
|
||||||
torr.TorrentSpec = spec
|
torr.TorrentSpec = spec
|
||||||
torr.AddExpiredTime(time.Second * time.Duration(settings.BTsets.TorrentDisconnectTimeout))
|
torr.AddExpiredTime(timeout)
|
||||||
torr.Timestamp = time.Now().Unix()
|
torr.Timestamp = time.Now().Unix()
|
||||||
|
|
||||||
go torr.watch()
|
go torr.watch()
|
||||||
|
|||||||
Reference in New Issue
Block a user