Chromium Code Reviews| Index: common/gcloud/gs/gs.go |
| diff --git a/common/gcloud/gs/gs.go b/common/gcloud/gs/gs.go |
| index be2bdee9a2844cedb787777cc1b284bde9b9a05c..109ceb12e8af04f71dbe5e0dea81316a1f070f27 100644 |
| --- a/common/gcloud/gs/gs.go |
| +++ b/common/gcloud/gs/gs.go |
| @@ -37,7 +37,10 @@ type Client interface { |
| io.Closer |
| // NewReader instantiates a new Reader instance for the named bucket/path. |
| - NewReader(p Path, o Options) (io.ReadCloser, error) |
| + // |
| + // If the supplied offset is <0, it will default to 0. If the supplied length |
| + // is <0, no upper byte bound will be set. |
|
nodir
2016/04/19 23:41:16
why not accept uint64 or panic? if someone passes
dnj
2016/04/20 00:45:07
We generally don't do uint64 in our code, even for
nodir
2016/04/20 16:42:57
ok, why not panic? If there is a negative value, i
dnj
2016/04/20 17:07:25
Sure, I'll panic if offset is <0.
|
| + NewReader(p Path, offset int64, length int64) (io.ReadCloser, error) |
|
nodir
2016/04/19 23:41:16
nit: offset, length int64
dnj
2016/04/20 00:45:07
Done.
|
| // NewWriter instantiates a new Writer instance for the named bucket/path. |
| NewWriter(p Path) (Writer, error) |
| @@ -55,19 +58,6 @@ type Client interface { |
| Rename(src, dst Path) error |
| } |
| -// Options are the set of extra options to apply to the Google Storage request. |
| -type Options struct { |
| - // From is the range request starting index. If >0, the beginning of the |
| - // range request will be set. |
| - From int64 |
| - // To is the range request ending index. If >0, the end of the |
| - // range request will be set. |
| - // |
| - // If no From index is set, this will result in a request indexed from the end |
| - // of the object. |
| - To int64 |
| -} |
| - |
| // prodGSObject is an implementation of Client interface using the production |
| // Google Storage client. |
| type prodClient struct { |
| @@ -116,19 +106,16 @@ func (c *prodClient) NewWriter(p Path) (Writer, error) { |
| }, nil |
| } |
| -func (c *prodClient) NewReader(p Path, o Options) (io.ReadCloser, error) { |
| - if o.From < 0 { |
| - o.From = 0 |
| - } |
| - if o.To <= 0 { |
| - o.To = -1 |
| +func (c *prodClient) NewReader(p Path, offset int64, length int64) (io.ReadCloser, error) { |
|
nodir
2016/04/19 23:41:16
nit: offset, length int64
dnj
2016/04/20 00:45:07
Done.
|
| + if offset < 0 { |
| + offset = 0 |
| } |
| obj, err := c.handleForPath(p) |
| if err != nil { |
| return nil, err |
| } |
| - return obj.NewRangeReader(c, o.From, o.To) |
| + return obj.NewRangeReader(c, offset, length) |
| } |
| func (c *prodClient) Rename(src, dst Path) error { |