From e9a21c1dc62b62d14abb2f1435f0a5ecf361e2a0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 4 Feb 2016 19:37:33 +0100 Subject: [PATCH] backend.LoadAll: return nil on expected error The current code returns io.ErrUnexpectedEOF, but it is the normal, expected behaviour of the function LoadAll() to load until the item is completely loaded. Therefore, the io.ErrUnexpectedEOF is not returned to the caller. --- backend/utils.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/utils.go b/backend/utils.go index c40d35e12..e1c36236b 100644 --- a/backend/utils.go +++ b/backend/utils.go @@ -1,7 +1,11 @@ package backend +import "io" + // LoadAll reads all data stored in the backend for the handle. The buffer buf -// is resized to accomodate all data in the blob. +// is resized to accomodate all data in the blob. Errors returned by be.Load() +// are passed on, except io.ErrUnexpectedEOF is silenced and nil returned +// instead, since it means this function is working properly. func LoadAll(be Backend, h Handle, buf []byte) ([]byte, error) { fi, err := be.Stat(h) if err != nil { @@ -13,6 +17,9 @@ func LoadAll(be Backend, h Handle, buf []byte) ([]byte, error) { } n, err := be.Load(h, buf, 0) + if err == io.ErrUnexpectedEOF { + err = nil + } buf = buf[:n] return buf, err }