Merge pull request #129 from harshavardhana/pr_out_do_not_upload_already_uploaded_objects

This commit is contained in:
Harshavardhana
2015-03-15 17:46:08 -07:00
2 changed files with 10 additions and 11 deletions
+10 -9
View File
@@ -45,11 +45,20 @@ func (w *walk) putWalk(p string, i os.FileInfo, err error) error {
bodyFile, err := os.Open(p)
defer bodyFile.Close()
var size int64
size, _, err = w.s3.Stat(bucketname, key)
if os.IsExist(err) || size != 0 {
msg := fmt.Sprintf("%s is already uploaded -- to bucket:%s://%s/%s/%s",
key, w.s3.Scheme, w.s3.Host, bucketname, key)
info(msg)
return nil
}
err = w.s3.Put(bucketname, key, i.Size(), bodyFile)
if err != nil {
return err
}
msg := fmt.Sprintf("%s uploaded -- to bucket:http://%s/%s", key, bucketname, key)
msg := fmt.Sprintf("%s uploaded -- to bucket:%s://%s/%s/%s",
key, w.s3.Scheme, w.s3.Host, bucketname, key)
info(msg)
return nil
}
@@ -105,14 +114,6 @@ func doRecursiveCp(s3c *s3.Client, args *cmdArgs) error {
if err != nil {
return err
}
} else {
items, _, err := s3c.ListObjects(args.destination.bucket, "", "", "", s3.MaxKeys)
if err != nil {
return err
}
if len(items) != 0 {
return fmt.Errorf("destination bucket not empty")
}
}
err = filepath.Walk(input, p.putWalk)
if err != nil {
-2
View File
@@ -131,7 +131,6 @@ func (c *Client) Get(bucket, key string) (body io.ReadCloser, size int64, err er
if err != nil {
return nil, 0, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, 0, s3errors.New(res)
@@ -159,7 +158,6 @@ func (c *Client) GetPartial(bucket, key string, offset, length int64) (body io.R
if err != nil {
return
}
defer res.Body.Close()
switch res.StatusCode {
case http.StatusOK, http.StatusPartialContent: