pkg/blobserver/diskpacked: fail earlier in StreamBlobs

As Miki Habryn suggested at
https://groups.google.com/forum/#!topic/camlistore/WmUyUWMfZx0%5B1-25%5D

Change-Id: Ib910e5bcfa7eb33360f7b5e1085bd9bb1f0e9e6a
This commit is contained in:
Tamás Gulácsi 2015-07-18 21:42:16 +02:00 committed by Brad Fitzpatrick
parent 815575e493
commit 4754ab6c4b
1 changed files with 5 additions and 4 deletions

View File

@ -611,6 +611,11 @@ func (s *storage) StreamBlobs(ctx context.Context, dest chan<- blobserver.BlobAn
continue
}
ref, ok := blob.ParseBytes(digest)
if !ok {
return fmt.Errorf("diskpacked: Invalid blobref %q", digest)
}
// Finally, read and send the blob.
// TODO: remove this allocation per blob. We can make one instead
@ -624,10 +629,6 @@ func (s *storage) StreamBlobs(ctx context.Context, dest chan<- blobserver.BlobAn
return err
}
offset += int64(size)
ref, ok := blob.ParseBytes(digest)
if !ok {
return fmt.Errorf("diskpacked: Invalid blobref %q", digest)
}
newReader := func() readerutil.ReadSeekCloser {
return newReadSeekNopCloser(bytes.NewReader(data))
}