Skip to content

Commit f3c6fa6

Browse files
committed
Change percent calculation logic
1 parent 6c5fb65 commit f3c6fa6

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

app/azureBlobUploader.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,11 @@ this.setConfig = function (config) {
299299
libPath: config.libPath,
300300
maxBlockSize: maxBlockSize, //Each file will be split in 256 KB.
301301
numberOfBlocks: numberOfBlocks,
302-
totalBytesRemaining: fileSize,
303302
fileSize: fileSize,
304303
currentFilePointer: 0,
305304
blocks: [],
306305
blockIdPrefix: 'block-',
307306
blocksReadIndex: 0,
308-
bytesUploaded: 0,
309307
file: file,
310308
blobUri: config.blobUri,
311309
error: config.error,
@@ -360,10 +358,15 @@ this.upload = function () {
360358
};
361359

362360
var removeProcessedAction = function (block, action, result) {
363-
state.bytesUploaded += block.size;
364-
state.totalBytesRemaining -= block.size;
361+
var totalBytesUploaded = state.blocks.filter(function(s) {
362+
return s.resolved;
363+
}).map(function(s) {
364+
return s.size;
365+
}).reduce(function(a, b){
366+
return a + b;
367+
});
365368

366-
var percentComplete = ((parseFloat(block.size) / parseFloat(state.file.size)) * 100).toFixed(2);
369+
var percentComplete = ((parseFloat(totalBytesUploaded) / parseFloat(state.file.size)) * 100).toFixed(2);
367370

368371
progress({
369372
result: result,

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-azure-blob",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"dependencies": {
55
"angular": "latest",
66
"underscore": "latest",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-azure-blob",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"description": "Angular Azure blob upload helper",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)