mirror of https://github.com/rclone/rclone.git
fs: fix FixRangeOption so it works with 0 length files
This commit is contained in:
parent
629b7eacd8
commit
95af1f9ccf
|
@ -139,6 +139,17 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
|
||||||
// not exceed filesize. Some remotes (eg Onedrive, Box) don't support
|
// not exceed filesize. Some remotes (eg Onedrive, Box) don't support
|
||||||
// range requests which index from the end.
|
// range requests which index from the end.
|
||||||
func FixRangeOption(options []OpenOption, size int64) {
|
func FixRangeOption(options []OpenOption, size int64) {
|
||||||
|
if size == 0 {
|
||||||
|
// if size 0 then remove RangeOption~s
|
||||||
|
// replacing with an empty HTTPOption~s which won't be rendered
|
||||||
|
for i := range options {
|
||||||
|
if _, ok := options[i].(*RangeOption); ok {
|
||||||
|
options[i] = &HTTPOption{}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
for i := range options {
|
for i := range options {
|
||||||
option := options[i]
|
option := options[i]
|
||||||
if x, ok := option.(*RangeOption); ok {
|
if x, ok := option.(*RangeOption); ok {
|
||||||
|
@ -148,7 +159,7 @@ func FixRangeOption(options []OpenOption, size int64) {
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
if x.End > size {
|
if x.End > size {
|
||||||
x = &RangeOption{Start: x.Start, End: size}
|
x = &RangeOption{Start: x.Start, End: size - 1}
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue