From 829dd1ad25d3ecc57bfda85e475e841b61b40d51 Mon Sep 17 00:00:00 2001 From: remusb Date: Mon, 11 Dec 2017 01:15:53 +0200 Subject: [PATCH] cache: try a full read on the last chunk for #1896 --- cache/handle.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cache/handle.go b/cache/handle.go index c24295fec..747afb7c8 100644 --- a/cache/handle.go +++ b/cache/handle.go @@ -427,9 +427,10 @@ func (w *worker) run() { } chunkEnd := chunkStart + w.r.cacheFs().chunkSize - if chunkEnd > w.r.cachedObject.Size() { - chunkEnd = w.r.cachedObject.Size() - } + // TODO: Remove this comment if it proves to be reliable for #1896 + //if chunkEnd > w.r.cachedObject.Size() { + // chunkEnd = w.r.cachedObject.Size() + //} w.download(chunkStart, chunkEnd, 0) } @@ -464,11 +465,12 @@ func (w *worker) download(chunkStart, chunkEnd int64, retry int) { w.download(chunkStart, chunkEnd, retry+1) return } - if err == io.ErrUnexpectedEOF { - fs.Debugf(w, "partial read chunk %v: %v", chunkStart, err) - } data = data[:sourceRead] // reslice to remove extra garbage - fs.Debugf(w, "downloaded chunk %v", fs.SizeSuffix(chunkStart)) + if err == io.ErrUnexpectedEOF { + fs.Debugf(w, "partial downloaded chunk %v", fs.SizeSuffix(chunkStart)) + } else { + fs.Debugf(w, "downloaded chunk %v", fs.SizeSuffix(chunkStart)) + } if w.r.UseMemory { err = w.r.memory.AddChunk(w.r.cachedObject.abs(), data, chunkStart)