@ -47,8 +47,8 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) {
if size < 4096 {
if size < 4096 {
bs , err := ioutil . ReadAll ( io . LimitReader ( rd , size ) )
bs , err := ioutil . ReadAll ( io . LimitReader ( rd , size ) )
defer cancel ( )
if err != nil {
if err != nil {
cancel ( )
return nil , err
return nil , err
}
}
_ , err = rd . Discard ( 1 )
_ , err = rd . Discard ( 1 )
@ -106,12 +106,12 @@ func (b *blobReader) Read(p []byte) (n int, err error) {
// Close implements io.Closer
// Close implements io.Closer
func ( b * blobReader ) Close ( ) error {
func ( b * blobReader ) Close ( ) error {
defer b . cancel ( )
if b . n > 0 {
if b . n > 0 {
for b . n > math . MaxInt32 {
for b . n > math . MaxInt32 {
n , err := b . rd . Discard ( math . MaxInt32 )
n , err := b . rd . Discard ( math . MaxInt32 )
b . n -= int64 ( n )
b . n -= int64 ( n )
if err != nil {
if err != nil {
b . cancel ( )
return err
return err
}
}
b . n -= math . MaxInt32
b . n -= math . MaxInt32
@ -119,14 +119,12 @@ func (b *blobReader) Close() error {
n , err := b . rd . Discard ( int ( b . n ) )
n , err := b . rd . Discard ( int ( b . n ) )
b . n -= int64 ( n )
b . n -= int64 ( n )
if err != nil {
if err != nil {
b . cancel ( )
return err
return err
}
}
}
}
if b . n == 0 {
if b . n == 0 {
_ , err := b . rd . Discard ( 1 )
_ , err := b . rd . Discard ( 1 )
b . n --
b . n --
b . cancel ( )
return err
return err
}
}
return nil
return nil