change reader close

This commit is contained in:
YouROK
2020-12-22 20:41:13 +03:00
parent b2fb4e1f30
commit 7fdefa923e

View File

@@ -272,13 +272,16 @@ func (t *Torrent) Preload(index int, size int64) {
// Reader for not pieces break in cache without readers // Reader for not pieces break in cache without readers
readerStart := t.cache.NewReader(file) readerStart := t.cache.NewReader(file)
readerStart.Read(make([]byte, 1)) readerStart.Read(make([]byte, 1))
defer t.cache.CloseReader(readerStart) defer t.CloseReader(readerStart)
readerEnd := t.cache.NewReader(file) readerEnd := t.cache.NewReader(file)
readerEnd.Seek(-1024, io.SeekEnd) readerEnd.Seek(-1024, io.SeekEnd)
readerEnd.Read(make([]byte, 1)) readerEnd.Read(make([]byte, 1))
defer t.cache.CloseReader(readerEnd) defer t.CloseReader(readerEnd)
pl := t.Info().PieceLength pl := t.Info().PieceLength
lastStat := "" 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 {