Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types to remove ResumableFile.progress argument, add ResumableChunk progress type #521

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RowiDont
Copy link

I might be misinterpreting the source code, but I think the ResumableFile.progress function doesn't seem to take any arguments, where the ResumableChunk.progress does take an optional argument.

I was initially going to just make the ResumableFile.progress argument optional, and while that will fix the issue I'm running in to, I found what I thought was a larger issue, thus my type changes.

In ResumableFile:

      $.progress = function(){
        if(_error) return(1);
        // Sum up progress across everything
        var ret = 0;
        var error = false;
        $h.each($.chunks, function(c){
          if(c.status()=='error') error = true;
          ret += c.progress(true); // get chunk progress relative to entire file
        });
        ret = (error ? 1 : (ret>0.99999 ? 1 : ret));
        ret = Math.max($._prevProgress, ret); // We don't want to lose percentages when an upload is paused
        $._prevProgress = ret;
        return(ret);
      };

And in ResumableChunk:

      $.progress = function(relative){
        if(typeof(relative)==='undefined') relative = false;
        var factor = (relative ? ($.endByte-$.startByte)/$.fileObjSize : 1);
        if($.pendingRetry) return(0);
        if((!$.xhr || !$.xhr.status) && !$.markComplete) factor*=.95;
        var s = $.status();
        switch(s){
        case 'success':
        case 'error':
          return(1*factor);
        case 'pending':
          return(0*factor);
        default:
          return($.loaded/($.endByte-$.startByte)*factor);
        }
      };

@RowiDont RowiDont changed the title Update types to make ResumableFile.progress argument optional. Update types to remove ResumableFile.progress argument, add ResumableChunk progress type Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant