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

azureblob: fix incorrect size after --azureblob-no-head-object patch

Nick Craig-Woodeb0c8284f13a
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index b1f657c71..84eeebedd 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -16,6 +16,7 @@ import (
"net/http"
"net/url"
"path"
+ "strconv"
"strings"
"sync"
"time"
@@ -1388,6 +1389,21 @@ func (o *Object) decodeMetaDataFromDownloadResponse(info *azblob.DownloadRespons
o.accessTier = o.AccessTier()
o.setMetadata(metadata)
+ // If it was a Range request, the size is wrong, so correct it
+ if contentRange := info.ContentRange(); contentRange != "" {
+ slash := strings.IndexRune(contentRange, '/')
+ if slash >= 0 {
+ i, err := strconv.ParseInt(contentRange[slash+1:], 10, 64)
+ if err == nil {
+ o.size = i
+ } else {
+ fs.Debugf(o, "Failed to find parse integer from in %q: %v", contentRange, err)
+ }
+ } else {
+ fs.Debugf(o, "Failed to find length in %q", contentRange)
+ }
+ }
+
return nil
}