From eeb8f61dd3156f847e99e406acbe61e68ffebc4c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 19 Jan 2015 15:04:54 -0800 Subject: [PATCH] client: make Fetch return os.ErrNotExist on 404, per blob.Fetcher contract Change-Id: I8a554c6facb34f2257e3e6035030e404a051ec50 --- pkg/client/get.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/client/get.go b/pkg/client/get.go index 8d5c0512f..dbb6f43a9 100644 --- a/pkg/client/get.go +++ b/pkg/client/get.go @@ -22,6 +22,8 @@ import ( "fmt" "io" "math" + "net/http" + "os" "regexp" "camlistore.org/pkg/blob" @@ -103,8 +105,11 @@ func (c *Client) FetchVia(b blob.Ref, v []blob.Ref) (body io.ReadCloser, size ui resp.Body.Close() } }() - - if resp.StatusCode != 200 { + if resp.StatusCode == http.StatusNotFound { + // Per blob.Fetcher contract: + return nil, 0, os.ErrNotExist + } + if resp.StatusCode != http.StatusOK { return nil, 0, fmt.Errorf("Got status code %d from blobserver for %s", resp.StatusCode, b) }