Skip to content

Commit

Permalink
Make sure fileSuccess event are not fired before the server has ret…
Browse files Browse the repository at this point in the history
…urned.

Do you remember installing Windows 95? How it got to 95% done and then hung for the next few hours without any progress. This commit brings the awesomeness of this to Resumable.js as well.

Before, we use the upload progress as an indicator of the full upload process -- this meant that `fileSuccess` would fire before the server had returned its status code in some cases. Since we rely on that status code, a simple padding has been made of the last 5% of the progress of each individual chunks is actually assigned to the server returning -- instead of to the pure bytes being updated. 

Given small enough chunk sizes, this should now affect the user experience of using resumable.
  • Loading branch information
steffentchr committed Feb 4, 2016
1 parent f0ffdc9 commit d86cbf9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions resumable.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@
if(typeof(relative)==='undefined') relative = false;
var factor = (relative ? ($.endByte-$.startByte)/$.fileObjSize : 1);
if($.pendingRetry) return(0);
if(!$.xhr || !$.xhr.status) factor*=.95;
var s = $.status();
switch(s){
case 'success':
Expand Down

0 comments on commit d86cbf9

Please sign in to comment.