refactor chunk upload: return offset, continue at server offset

This commit is contained in:
j 2014-04-11 16:56:22 +00:00
commit 7cd152b1d5
8 changed files with 133 additions and 161 deletions

View file

@ -162,7 +162,15 @@ pandora.chunkupload = function(options) {
nextChunkId = chunkId + 1;
that.triggerEvent('paused', {next: nextChunkId});
} else {
uploadChunk(chunkId + 1);
if (Ox.isUndefined(response.offset) ||
response.offset == (chunkId +1) * chunkSize) {
uploadChunk(chunkId + 1);
} else {
// continue at chunk closest to offset from server
console.log('server offset', response.offset,
'next chunk', Math.floor(response.offset / chuknSize));
uploadChunk(Math.floor(response.offset / chuknSize));
}
}
} else {
// failed to upload, try again in 5 second