forked from TrueCloudLab/rclone
fs: fix FixRangeOption to do nothing on unknown sized objects
FixRangeOption shouldn't be called on an object of unknown size, but if it is, make sure it does nothing. See: #5642
This commit is contained in:
parent
f6fd6ee777
commit
cf0a72aecd
2 changed files with 14 additions and 1 deletions
|
@ -142,7 +142,10 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
|
||||||
// It also adjusts any SeekOption~s, turning them into absolute
|
// It also adjusts any SeekOption~s, turning them into absolute
|
||||||
// RangeOption~s instead.
|
// RangeOption~s instead.
|
||||||
func FixRangeOption(options []OpenOption, size int64) {
|
func FixRangeOption(options []OpenOption, size int64) {
|
||||||
if size == 0 {
|
if size < 0 {
|
||||||
|
// Can't do anything for unknown length objects
|
||||||
|
return
|
||||||
|
} else if size == 0 {
|
||||||
// if size 0 then remove RangeOption~s
|
// if size 0 then remove RangeOption~s
|
||||||
// replacing with a NullOptions~s which won't be rendered
|
// replacing with a NullOptions~s which won't be rendered
|
||||||
for i := range options {
|
for i := range options {
|
||||||
|
|
|
@ -149,6 +149,16 @@ func TestFixRangeOptions(t *testing.T) {
|
||||||
in: []OpenOption{},
|
in: []OpenOption{},
|
||||||
want: []OpenOption{},
|
want: []OpenOption{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Unknown size -1",
|
||||||
|
in: []OpenOption{
|
||||||
|
&RangeOption{Start: 1, End: -1},
|
||||||
|
},
|
||||||
|
want: []OpenOption{
|
||||||
|
&RangeOption{Start: 1, End: -1},
|
||||||
|
},
|
||||||
|
size: -1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Fetch a range with size=0",
|
name: "Fetch a range with size=0",
|
||||||
in: []OpenOption{
|
in: []OpenOption{
|
||||||
|
|
Loading…
Reference in a new issue