1
mirror of https://github.com/rclone/rclone synced 2024-11-30 09:10:05 +01:00

backend/http: if HEAD didn't return Content-Length use -1 as size

This means that the files will be treated as an unknown length and
will download properly.

Fixes #2247
This commit is contained in:
Nick Craig-Wood 2018-04-16 19:40:02 +01:00
parent 2b7957cc74
commit b83814082b

View File

@ -189,10 +189,11 @@ func (f *Fs) url(remote string) string {
return f.endpointURL + rest.URLPathEscape(remote)
}
func parseInt64(s string) int64 {
// parse s into an int64, on failure return def
func parseInt64(s string, def int64) int64 {
n, e := strconv.ParseInt(s, 10, 64)
if e != nil {
return 0
return def
}
return n
}
@ -409,7 +410,7 @@ func (o *Object) stat() error {
if err != nil {
t = timeUnset
}
o.size = parseInt64(res.Header.Get("Content-Length"))
o.size = parseInt64(res.Header.Get("Content-Length"), -1)
o.modTime = t
o.contentType = res.Header.Get("Content-Type")
return nil