mirror of https://github.com/perkeep/perkeep.git
s3: style fixes
Change-Id: I0c8dacb00f57d374c3148fe5c8017a9f146d36f4
This commit is contained in:
parent
119b38966a
commit
1f75759371
|
@ -282,25 +282,20 @@ func (c *Client) ListBucket(bucket string, startAt string, maxKeys int) (items [
|
||||||
func (c *Client) Get(bucket, key string) (body io.ReadCloser, size int64, err error) {
|
func (c *Client) Get(bucket, key string) (body io.ReadCloser, size int64, err error) {
|
||||||
req := newReq(c.keyURL(bucket, key))
|
req := newReq(c.keyURL(bucket, key))
|
||||||
c.Auth.SignRequest(req)
|
c.Auth.SignRequest(req)
|
||||||
var res *http.Response
|
res, err := c.transport().RoundTrip(req)
|
||||||
res, err = c.transport().RoundTrip(req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK && res != nil && res.Body != nil {
|
switch res.StatusCode {
|
||||||
defer func() {
|
case http.StatusOK:
|
||||||
io.Copy(os.Stderr, res.Body)
|
return res.Body, res.ContentLength, nil
|
||||||
}()
|
case http.StatusNotFound:
|
||||||
|
res.Body.Close()
|
||||||
|
return nil, 0, os.ErrNotExist
|
||||||
|
default:
|
||||||
|
res.Body.Close()
|
||||||
|
return nil, 0, fmt.Errorf("Amazon HTTP error on GET: %d", res.StatusCode)
|
||||||
}
|
}
|
||||||
if res.StatusCode == http.StatusNotFound {
|
|
||||||
err = os.ErrNotExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if res.StatusCode != http.StatusOK {
|
|
||||||
err = fmt.Errorf("Amazon HTTP error on GET: %d", res.StatusCode)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return res.Body, res.ContentLength, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Delete(bucket, key string) error {
|
func (c *Client) Delete(bucket, key string) error {
|
||||||
|
|
Loading…
Reference in New Issue