From b5286499e0a388ac7fd895ea34a9576664ec4223 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 11 Apr 2015 13:38:56 +0200 Subject: [PATCH] advance next block by response size instead of requested size --- static/js/fs.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/static/js/fs.js b/static/js/fs.js index 6a897dda..6f766d34 100644 --- a/static/js/fs.js +++ b/static/js/fs.js @@ -204,14 +204,15 @@ pandora.fs = (function() { partialDownload(0); }); function partialDownload(offset) { - var end = offset + blobSize; + var end = offset + blobSize - 1; if (total) { - end = Math.min(end, total); + end = Math.min(end, total - 1); } - Ox.Log('FS', 'download part', url, offset, end); + var range = 'bytes=' + offset + '-' + end; + Ox.Log('FS', 'download part', url, offset, end, total, range); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); - xhr.setRequestHeader('Range', 'bytes=' + offset + '-' + end); + xhr.setRequestHeader('Range', range); xhr.withCredentials = true; xhr.responseType = 'blob'; xhr.timeout = 1000 * 60 * 5; @@ -236,8 +237,8 @@ pandora.fs = (function() { var blob = xhr.response; setTimeout(function() { that.storeBlob(blob, partialName, function(response) { - if (offset + blobSize < total) { - partialDownload(offset + blobSize + 1); + if (offset + blob.size < total) { + partialDownload(offset + blob.size); } else { renameFile(partialName, name, function(fileEntry) { if (fileEntry) {