forked from TrueCloudLab/rclone
onedrive: Overwrite object size value with real size when reading file.
Because of a bug in the Onedrive API it will sometime report the wrong size. If the size is wrong other remotes that depend on the size might fail. To fix this we overwrite the objects size with the real size from ContentLength header.
This commit is contained in:
parent
8a9ed57951
commit
2f63a9f81c
1 changed files with 5 additions and 0 deletions
|
@ -1079,6 +1079,11 @@ func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusOK && resp.ContentLength > 0 && resp.Header.Get("Content-Range") == "" {
|
||||
//Overwrite size with actual size since size readings from Onedrive is unreliable.
|
||||
o.size = resp.ContentLength
|
||||
}
|
||||
return resp.Body, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue