mirror of https://github.com/perkeep/perkeep.git
client: make Fetch return os.ErrNotExist on 404, per blob.Fetcher contract
Change-Id: I8a554c6facb34f2257e3e6035030e404a051ec50
This commit is contained in:
parent
d251a9b367
commit
eeb8f61dd3
|
@ -22,6 +22,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"camlistore.org/pkg/blob"
|
"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()
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
if resp.StatusCode != 200 {
|
// 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)
|
return nil, 0, fmt.Errorf("Got status code %d from blobserver for %s", resp.StatusCode, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue