From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Sun, 16 Oct 2022 04:47:18 +0000 (+0800) Subject: fix X-Git-Tag: v0.10.8 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=3c8582d2b1ab14bc0475ba2491c5738fb9c8063d;p=part%2F.git fix --- diff --git a/file/FileWR.go b/file/FileWR.go index f021e48..063b6a1 100644 --- a/file/FileWR.go +++ b/file/FileWR.go @@ -127,11 +127,9 @@ func (t *File) ReadUntil(separation byte, perReadSize int, maxReadSize int) (dat n, e = t.read().Read(tmpArea) if n == 0 && e != nil { - if errors.Is(e, io.EOF) { - e = nil - } return } + maxReadSize = maxReadSize - n if i := bytes.Index(tmpArea[:n], []byte{separation}); i != -1 { diff --git a/file/FileWR_test.go b/file/FileWR_test.go index 4753577..801c0ee 100644 --- a/file/FileWR_test.go +++ b/file/FileWR_test.go @@ -2,6 +2,8 @@ package part import ( "bytes" + "errors" + "io" "testing" "golang.org/x/text/encoding/simplifiedchinese" @@ -156,6 +158,12 @@ func TestReadUntil(t *testing.T) { t.Fatal(string(data)) } + if data, e := f.ReadUntil('\n', 5, 20); e == nil || !errors.Is(e, io.EOF) { + t.Fatal(e) + } else { + t.Log(string(data)) + } + if e := f.Close(); e != nil { t.Fatal(e) }