mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
fix bug when torrent preload and close it
This commit is contained in:
@@ -283,23 +283,25 @@ func (t *Torrent) Preload(index int, size int64) {
|
|||||||
readerEnd.Read(make([]byte, 1))
|
readerEnd.Read(make([]byte, 1))
|
||||||
defer t.CloseReader(readerEnd)
|
defer t.CloseReader(readerEnd)
|
||||||
|
|
||||||
pl := t.Info().PieceLength
|
if t.Info() != nil {
|
||||||
lastStat := ""
|
pl := t.Info().PieceLength
|
||||||
|
lastStat := ""
|
||||||
|
|
||||||
for t.PreloadedBytes < size-pl {
|
for t.PreloadedBytes < size-pl {
|
||||||
t.muTorrent.Lock()
|
t.muTorrent.Lock()
|
||||||
if t.Torrent == nil {
|
if t.Torrent == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.PreloadedBytes = t.Torrent.BytesCompleted()
|
t.PreloadedBytes = t.Torrent.BytesCompleted()
|
||||||
t.muTorrent.Unlock()
|
t.muTorrent.Unlock()
|
||||||
|
|
||||||
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().ConnectedSeeders, "]", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers)
|
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().ConnectedSeeders, "]", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers)
|
||||||
if stat != lastStat {
|
if stat != lastStat {
|
||||||
log.TLogln("Preload:", stat)
|
log.TLogln("Preload:", stat)
|
||||||
lastStat = stat
|
lastStat = stat
|
||||||
|
}
|
||||||
|
time.Sleep(time.Millisecond * 1000)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Millisecond * 1000)
|
|
||||||
}
|
}
|
||||||
log.TLogln("End preload:", file.Torrent().InfoHash().HexString(), "Peers:[", t.Torrent.Stats().ConnectedSeeders, "]", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers)
|
log.TLogln("End preload:", file.Torrent().InfoHash().HexString(), "Peers:[", t.Torrent.Stats().ConnectedSeeders, "]", t.Torrent.Stats().ActivePeers, "/", t.Torrent.Stats().TotalPeers)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user