mirror of
https://github.com/rclone/rclone.git
synced 2025-08-13 15:37:26 +02:00
fs: Adjust RangeOption.Decode to return -1 for read to end
A Range request can never request 0 bytes however this change was made to make a clearer signal that the limit means read to the end. Add test and more documentation and fixup uses
This commit is contained in:
@ -855,11 +855,11 @@ func (file *ObjectReader) Close() (err error) {
|
||||
|
||||
// Open a remote sftp file object for reading. Seek is supported
|
||||
func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) {
|
||||
var offset, limit int64
|
||||
var offset, limit int64 = 0, -1
|
||||
for _, option := range options {
|
||||
switch x := option.(type) {
|
||||
case *fs.SeekOption:
|
||||
offset, limit = x.Offset, 0
|
||||
offset = x.Offset
|
||||
case *fs.RangeOption:
|
||||
offset, limit = x.Decode(o.Size())
|
||||
default:
|
||||
|
Reference in New Issue
Block a user