From 9c451252712f0e89d710fe477ef99b8641e899c2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 21 Jan 2018 17:10:10 +0000 Subject: [PATCH] azureblob: fix RangeOption support in Open #1825 --- backend/azureblob/azureblob.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 20d09c49f..113af3567 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -854,14 +854,21 @@ func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) { for _, option := range options { switch x := option.(type) { case *fs.RangeOption: + start, end := x.Start, x.End + if end < 0 { + end = 0 + } + if start < 0 { + start = o.size - end + end = 0 + } getBlobRangeOptions.Range = &storage.BlobRange{ - Start: uint64(x.Start), - End: uint64(x.End), + Start: uint64(start), + End: uint64(end), } case *fs.SeekOption: getBlobRangeOptions.Range = &storage.BlobRange{ Start: uint64(x.Offset), - End: uint64(o.size), } default: if option.Mandatory() {