mirror of
https://github.com/rclone/rclone.git
synced 2025-02-22 09:23:11 +08:00
azureblob: fix incorrect size after --azureblob-no-head-object patch
In 05f128868f47b1b5 azureblob: add --azureblob-no-head-object we incorrectly parsed the size of the object as the Content-Length of the returned header. This is incorrect in the presense of Range requests. This fixes the problem by parsing the Content-Range header if avaialble to read the correct length from if a Range request was issued. See: #5734
This commit is contained in:
parent
f5c7c597ba
commit
eb0c8284f1
@ -16,6 +16,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -1388,6 +1389,21 @@ func (o *Object) decodeMetaDataFromDownloadResponse(info *azblob.DownloadRespons
|
|||||||
o.accessTier = o.AccessTier()
|
o.accessTier = o.AccessTier()
|
||||||
o.setMetadata(metadata)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user