From 8ac77aa482010443dd57d1734d0a65ba1db3f0e3 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 18 Mar 2021 16:41:32 +0300 Subject: [PATCH] fix readahead --- server/torr/storage/torrstor/reader.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/torr/storage/torrstor/reader.go b/server/torr/storage/torrstor/reader.go index 28be26f..c659b6b 100644 --- a/server/torr/storage/torrstor/reader.go +++ b/server/torr/storage/torrstor/reader.go @@ -90,6 +90,9 @@ func (r *Reader) Read(p []byte) (n int, err error) { } func (r *Reader) SetReadahead(length int64) { + if length > r.cache.capacity { + length = r.cache.capacity + } r.Reader.SetReadahead(length) r.readahead = length }