diff --git a/server/torr/storage/torrstor/reader.go b/server/torr/storage/torrstor/reader.go index c3113b3..ce191c1 100644 --- a/server/torr/storage/torrstor/reader.go +++ b/server/torr/storage/torrstor/reader.go @@ -94,6 +94,12 @@ func (r *Reader) Read(p []byte) (n int, err error) { } func (r *Reader) SetReadahead(length int64) { + if time.Now().Unix() > r.lastAccess+60 && r.cache != nil && len(r.cache.readers) > 1 { + //fix read a head on not readed reader + r.Reader.SetReadahead(0) + r.readahead = 0 + return + } if r.cache != nil && length > r.cache.capacity { length = r.cache.capacity } @@ -114,7 +120,7 @@ func (r *Reader) Close() { // this struct close in cache r.isClosed = true if len(r.file.Torrent().Files()) > 0 { - r.Reader.Close() + r.Reader.Close() } go r.cache.getRemPieces() }