fixing gcs upload, wip

This commit is contained in:
Jarek Kowalski
2016-06-04 06:50:34 -07:00
parent 47c6f4c1bc
commit b9912a595f

View File

@@ -91,11 +91,23 @@ func (gcs *gcsStorage) PutBlock(b string, data io.ReadCloser, options PutOptions
}
defer data.Close()
t0 := time.Now()
call := gcs.objectsService.Insert(gcs.BucketName, &object).Media(data)
if !options.Overwrite {
call = call.IfGenerationMatch(0)
}
_, err := call.Do()
dt := time.Since(t0)
log.Printf("PutBlock completed in %v and returned %v", dt, err)
if err != nil {
if err, ok := err.(*googleapi.Error); ok {
if err.Code == 412 {
// Condition not met indicates that the block already exists.
return nil
}
}
}
return err
}