mirror of https://github.com/perkeep/perkeep.git
Amazon: untested delete support
This commit is contained in:
parent
df73e53494
commit
da0cb14ab8
|
@ -27,6 +27,14 @@ import (
|
|||
var _ = log.Printf
|
||||
|
||||
func (sto *s3Storage) Remove(partition blobserver.Partition, blobs []*blobref.BlobRef) os.Error {
|
||||
return os.NewError("NOIMPL")
|
||||
// TODO: do these in parallel
|
||||
var reterr os.Error
|
||||
for _, blob := range blobs {
|
||||
if err := sto.s3Client.Delete(sto.bucket, blob.String()); err != nil {
|
||||
reterr = err
|
||||
}
|
||||
}
|
||||
return reterr
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -175,8 +175,27 @@ func (c *Client) Get(bucket, key string) (body io.ReadCloser, size int64, err os
|
|||
return
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
err = fmt.Errorf("Amazon HTTP error on GET: %d", res.Status)
|
||||
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) os.Error {
|
||||
url := fmt.Sprintf("http://%s.s3.amazonaws.com/%s", bucket, key)
|
||||
req := newReq(url)
|
||||
req.Method = "DELETE"
|
||||
c.Auth.SignRequest(req)
|
||||
res, err := c.httpClient().Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if res != nil && res.Body != nil {
|
||||
defer res.Body.Close()
|
||||
}
|
||||
if res.StatusCode == http.StatusNotFound || res.StatusCode == http.StatusNoContent ||
|
||||
res.StatusCode == http.StatusOK {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Amazon HTTP error on DELETE: %d", res.StatusCode)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue