mirror of
https://github.com/rclone/rclone.git
synced 2025-01-09 15:58:28 +01:00
fs/OpenOptions: Make FixRangeOption clamp range to filesize.
This commit is contained in:
parent
10ed455777
commit
dd3e912731
@ -135,9 +135,9 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
|
|||||||
|
|
||||||
// FixRangeOption looks through the slice of options and adjusts any
|
// FixRangeOption looks through the slice of options and adjusts any
|
||||||
// RangeOption~s found that request a fetch from the end into an
|
// RangeOption~s found that request a fetch from the end into an
|
||||||
// absolute fetch using the size passed in. Some remotes (eg
|
// absolute fetch using the size passed in and makes sure the range does
|
||||||
// Onedrive, Box) don't support range requests which index from the
|
// not exceed filesize. Some remotes (eg Onedrive, Box) don't support
|
||||||
// end.
|
// range requests which index from the end.
|
||||||
func FixRangeOption(options []OpenOption, size int64) {
|
func FixRangeOption(options []OpenOption, size int64) {
|
||||||
for i := range options {
|
for i := range options {
|
||||||
option := options[i]
|
option := options[i]
|
||||||
@ -147,6 +147,10 @@ func FixRangeOption(options []OpenOption, size int64) {
|
|||||||
x = &RangeOption{Start: size - x.End, End: -1}
|
x = &RangeOption{Start: size - x.End, End: -1}
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
|
if x.End > size {
|
||||||
|
x = &RangeOption{Start: x.Start, End: size}
|
||||||
|
options[i] = x
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user