mirror of
https://github.com/rclone/rclone.git
synced 2024-11-08 01:25:14 +01:00
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
@ -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…
Reference in New Issue
Block a user