forked from 0x2620/pandora
advance next block by response size instead of requested size
This commit is contained in:
parent
122342db11
commit
b5286499e0
1 changed files with 7 additions and 6 deletions
|
@ -204,14 +204,15 @@ pandora.fs = (function() {
|
||||||
partialDownload(0);
|
partialDownload(0);
|
||||||
});
|
});
|
||||||
function partialDownload(offset) {
|
function partialDownload(offset) {
|
||||||
var end = offset + blobSize;
|
var end = offset + blobSize - 1;
|
||||||
if (total) {
|
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();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
xhr.setRequestHeader('Range', 'bytes=' + offset + '-' + end);
|
xhr.setRequestHeader('Range', range);
|
||||||
xhr.withCredentials = true;
|
xhr.withCredentials = true;
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
xhr.timeout = 1000 * 60 * 5;
|
xhr.timeout = 1000 * 60 * 5;
|
||||||
|
@ -236,8 +237,8 @@ pandora.fs = (function() {
|
||||||
var blob = xhr.response;
|
var blob = xhr.response;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
that.storeBlob(blob, partialName, function(response) {
|
that.storeBlob(blob, partialName, function(response) {
|
||||||
if (offset + blobSize < total) {
|
if (offset + blob.size < total) {
|
||||||
partialDownload(offset + blobSize + 1);
|
partialDownload(offset + blob.size);
|
||||||
} else {
|
} else {
|
||||||
renameFile(partialName, name, function(fileEntry) {
|
renameFile(partialName, name, function(fileEntry) {
|
||||||
if (fileEntry) {
|
if (fileEntry) {
|
||||||
|
|
Loading…
Reference in a new issue