asyncreader: make ErrorStreamAbandoned public

vfs-used-is-size
Nick Craig-Wood 2020-04-04 12:21:20 +01:00
parent 07908f3f54
commit 49e5299a95
2 changed files with 5 additions and 4 deletions

View File

@ -21,7 +21,8 @@ const (
bufferCacheFlushTime = 5 * time.Second // flush the cached buffers after this long
)
var errorStreamAbandoned = errors.New("stream abandoned")
// ErrorStreamAbandoned is returned when the input is closed before the end of the stream
var ErrorStreamAbandoned = errors.New("stream abandoned")
// AsyncReader will do async read-ahead from the input reader
// and make the data available as an io.Reader.
@ -132,7 +133,7 @@ func (a *AsyncReader) fill() (err error) {
if !ok {
// Return an error to show fill failed
if a.err == nil {
return errorStreamAbandoned
return ErrorStreamAbandoned
}
return a.err
}

View File

@ -279,7 +279,7 @@ func testAsyncReaderClose(t *testing.T, writeto bool) {
// Abandon the copy
a.Abandon()
wg.Wait()
assert.Equal(t, errorStreamAbandoned, copyErr)
assert.Equal(t, ErrorStreamAbandoned, copyErr)
// t.Logf("Copied %d bytes, err %v", copyN, copyErr)
assert.True(t, copyN > 0)
}
@ -353,7 +353,7 @@ func TestAsyncReaderSkipBytes(t *testing.T) {
if initialRead >= len(data) {
assert.Equal(t, err, io.EOF)
} else {
assert.True(t, err == errorStreamAbandoned || err == io.EOF)
assert.True(t, err == ErrorStreamAbandoned || err == io.EOF)
}
}
})