mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:51:48 +08: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
|
||||
// RangeOption~s found that request a fetch from the end into an
|
||||
// absolute fetch using the size passed in. Some remotes (eg
|
||||
// Onedrive, Box) don't support range requests which index from the
|
||||
// end.
|
||||
// absolute fetch using the size passed in and makes sure the range does
|
||||
// not exceed filesize. Some remotes (eg Onedrive, Box) don't support
|
||||
// range requests which index from the end.
|
||||
func FixRangeOption(options []OpenOption, size int64) {
|
||||
for i := range options {
|
||||
option := options[i]
|
||||
|
@ -147,6 +147,10 @@ func FixRangeOption(options []OpenOption, size int64) {
|
|||
x = &RangeOption{Start: size - x.End, End: -1}
|
||||
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