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

drive: fix range requests on 0 length files

Nick Craig-Wood415eeca6cf5e
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index dc6ea4c8c..db02bbc73 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -2436,6 +2436,10 @@ func (o *baseObject) httpResponse(url, method string, options []fs.OpenOption) (
return req, nil, err
}
fs.OpenOptionAddHTTPHeaders(req.Header, options)
+ if o.bytes == 0 {
+ // Don't supply range requests for 0 length objects as they always fail
+ delete(req.Header, "Range")
+ }
err = o.fs.pacer.Call(func() (bool, error) {
res, err = o.fs.client.Do(req)
if err == nil {