From b83814082b702a3239ba1f4b0521d6d109126998 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 16 Apr 2018 19:40:02 +0100 Subject: [PATCH] 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 --- backend/http/http.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/http/http.go b/backend/http/http.go index f289f6f2d..05437b8a8 100644 --- a/backend/http/http.go +++ b/backend/http/http.go @@ -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