Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

onedrive: Overwrite object size value with real size when reading file.

Victor2f63a9f81cd5
diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go
index 068928010..874a6128f 100644
--- a/backend/onedrive/onedrive.go
+++ b/backend/onedrive/onedrive.go
@@ -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
}