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:
Victor 2018-02-16 14:21:26 +01:00 committed by Nick Craig-Wood
parent 8a9ed57951
commit 2f63a9f81c

View File

@ -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
}