client: make Fetch return os.ErrNotExist on 404, per blob.Fetcher contract

Change-Id: I8a554c6facb34f2257e3e6035030e404a051ec50
This commit is contained in:
Brad Fitzpatrick 2015-01-19 15:04:54 -08:00
parent d251a9b367
commit eeb8f61dd3
1 changed files with 7 additions and 2 deletions

View File

@ -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)
}