fix read a head on not readed reader

This commit is contained in:
YouROK
2021-08-21 10:40:22 +03:00
parent 4bdff0d3ff
commit 1c307d668c

View File

@@ -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
}